-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply a command to pure text of journal
field
#974
Comments
The formatting for For biblatex/tex/latex/biblatex/biblatex.def Lines 2836 to 2847 in 33468f1
Attempt 1 doesn't work because there is no field (and no field format) called Attempt 2 uses an existing field format, but breaks because Unfortunately \printfield [titlecase]{journaltitle}\setunit{\subtitlepunct }\printfield [titlecase]{journalsubtitle} This means Attempt 3 won't work (and also that no further variation on Attempt 3 will work). A variant on Attempt 4 is the way to go here. You need to operate on the raw \documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=authoryear, backend=biber]{biblatex}
\usepackage{xstring}
\newcommand\testchain[1]{%
\StrLeft{#1}{3}[\firstchar]%
\firstchar%
}
\DeclareFieldFormat{journaltitle:nickkolok}{\testchain{#1}}
\renewbibmacro*{journal}{%
\ifboolexpr{
test {\iffieldundef{journaltitle}}
and
test {\iffieldundef{journalsubtitle}}
}
{}
{\printtext[journaltitle]{%
\printfield[journaltitle:nickkolok]{journaltitle}%
\setunit{\subtitlepunct}%
\printfield[journalsubtitle:nickkolok]{journalsubtitle}}}}
\addbibresource{biblatex-examples.bib}
\begin{document}
\cite{sigfridsson}
\printbibliography
\end{document} For future issues that are not feature requests (like #968) or bug reports, I would indeed prefer if you would ask on TeX.SX or your favourite LaTeX help site. I would also really appreciate if you could include a small yet compilable example document instead of just code snippets that have to be pieced together to create a working document. |
Thank you very much, the solution works perfectly! |
I have some articles like this:
@article{erdos1945integral, title={Integral distances}, author={Erd{\H{o}}s, Paul}, doi={10.1090/S0002-9904-1945-08490-0}, journal={Bulletin of the American Mathematical Society}, volume={51}, number={12}, pages={996}, year={1945} }
And (for example) a simple command defined like this:
Indeed, it is much more complex, but still invokes
xstring
and operates on strings.I need to apply this command to the pure
Bulletin of the American Mathematical Society
string.Attempt 1.
No effect (AFAIK
journal
is just an alias forjournaltitle
, isn't it?)Attempt 2.
Error:
OK... let's see what's the problem:
We obtain:
Attempt 3
How about a little game with expansion?
Unfortunately, we get the same result (as in Attempt 2) for
and no effect (as in Attempt 1) for
Attempt 4
(it throws a
\GenericError
without\detokenize
).Both journal title and article title are truncated to 3 letters:
Paul Erdős. ‘Int’. In: Bul 51.12 (1945), p. 996. doi: 10.1090/S0002-9904- 1945-08490-0.
How do I achieve the desired result and what BibLaTeX versions allow me to do that?
P.S. I can post this question to TeX.SX if you prefer.
The text was updated successfully, but these errors were encountered: