# Change biblatex field format only when field has been replaced

In my document, I want to have all abbreviations consisting of consecutive capitals to be set 90 per cent of the font size. I can do that manually in the text. But if it comes to journal abbreviations, I dont know how to achieve this for citations.

A DeclareFieldFormat would not work because the field shortjournal is only used to overwrite the journal field when present. And I dont want to set the journal field 10 per cent smaller in all cases but only in the cases when the full journal title is replaced by shortjournal.

In short: How can I re-format the journal field in citations but only in those cases where they have been replaced by shortjournal, as in my MWE?

I'm compiling with XeLaTex.

M(not yet)WE:

\documentclass{book}
\usepackage{relsize}
\newcommand{\abk}{\textscale{0.9}}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@ARTICLE{AB,
author    = {Author Beta},
title     = {Title},
shortjournal = {ABC},
journal ={AllButCrash},
pages = {1-23},
year={2009}}
@ARTICLE{CD,
author    = {Changed Director},
title     = {Title},
journal ={Boring Texts},
pages = {23-42},
year={2019}}
\end{filecontents}

\usepackage[backend=biber,style=verbose-inote,sorting=nyt,bibencoding=utf8,citereset=chapter,citepages=separate,refsection=none,autocite=footnote,isbn=false,doi=false,url=false,eprint=false,date=short]{biblatex}

\DeclareSourcemap{
\maps[datatype=bibtex]{
%Shortjournal berücksichtigen
\map[overwrite]{
\step[fieldsource=shortjournal]
\step[fieldset=journal,origfieldval]
}
}
}

\begin{document}
A reference here.\footcite{AB} All Abbreviations in Capitals -- whom I call \abk{AAIC} -- should be in a font size 10 percent smaller. So that they don't look like THIS.\footcite{CD}

\end{document}


The data substitution you are attempting leaves no trace that such substitution took place. So, without further information, on biblatex's side we cannot know if a source map data change happened. But we could add such information by means of field annotations.

So, we could add one such annotation in the same map with:

\DeclareSourcemap{
\maps[datatype=bibtex]{
% Shortjournal berücksichtigen
\map[overwrite]{
\step[fieldsource=shortjournal, final]
\step[fieldset=journaltitle, origfieldval]
\step[fieldset=journaltitle+an, fieldvalue={=shortened}]
}
}
}


With that, the journaltitle field, when it has been substituted by shortjorunal in the source map, will also receive a field annotation =shortened, which we can then use as a conditional in the formatting directive:

\DeclareFieldFormat{journaltitle}{%
\iffieldannotation[journaltitle]{shortened}{%
\mkbibemph{\abk{#1}}%
}{%
\mkbibemph{#1}%
}%
}


In full:

\documentclass{book}

\usepackage{relsize}
\newcommand{\abk}{\textscale{0.9}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@Article{AB,
author       = {Author Beta},
title        = {Title},
shortjournal = {ABC},
journaltitle = {AllButCrash},
pages        = {1-23},
year         = {2009},
}
@Article{CD,
author       = {Changed Director},
title        = {Title},
journaltitle = {Boring Texts},
pages        = {23-42},
year         = {2019},
}
\end{filecontents}

\usepackage[
backend=biber,
style=verbose-inote,
sorting=nyt,
bibencoding=utf8,
citereset=chapter,
citepages=separate,
refsection=none,
autocite=footnote,
isbn=false,
doi=false,
url=false,
eprint=false,
date=short,
]{biblatex}

\DeclareSourcemap{
\maps[datatype=bibtex]{
% Shortjournal berücksichtigen
\map[overwrite]{
\step[fieldsource=shortjournal, final]
\step[fieldset=journaltitle, origfieldval]
\step[fieldset=journaltitle+an, fieldvalue={=shortened}]
}
}
}

\DeclareFieldFormat{journaltitle}{%
\iffieldannotation[journaltitle]{shortened}{%
\mkbibemph{\abk{#1}}%
}{%
\mkbibemph{#1}%
}%
}

\begin{document}
A reference here.\footcite{AB} All Abbreviations in Capitals -- whom I call
\abk{AAIC} -- should be in a font size 10 percent smaller. So that they don't
look like THIS.\footcite{CD}

\end{document}


Another alternative would be not to do any data substitution, and handle the conditional directly in the relevant bibmacro, in this case journal:

\documentclass{book}

\usepackage{relsize}
\newcommand{\abk}{\textscale{0.9}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@Article{AB,
author       = {Author Beta},
title        = {Title},
shortjournal = {ABC},
journaltitle = {AllButCrash},
pages        = {1-23},
year         = {2009},
}
@Article{CD,
author       = {Changed Director},
title        = {Title},
journaltitle = {Boring Texts},
pages        = {23-42},
year         = {2019},
}
\end{filecontents}

\usepackage[
backend=biber,
style=verbose-inote,
sorting=nyt,
bibencoding=utf8,
citereset=chapter,
citepages=separate,
refsection=none,
autocite=footnote,
isbn=false,
doi=false,
url=false,
eprint=false,
date=short,
]{biblatex}

\renewbibmacro*{journal}{%
\iffieldundef{shortjournal}
{\ifboolexpr{
test {\iffieldundef{journaltitle}}
and
test {\iffieldundef{journalsubtitle}}
}
{}
{\printtext[journaltitle]{%
\printfield[titlecase]{journaltitle}%
\setunit{\subtitlepunct}%
\printfield[titlecase]{journalsubtitle}}}}
{\printfield{shortjournal}}}

\DeclareFieldFormat{shortjournal}{\mkbibemph{\abk{#1}}}

\begin{document}
A reference here.\footcite{AB} All Abbreviations in Capitals -- whom I call
\abk{AAIC} -- should be in a font size 10 percent smaller. So that they don't
look like THIS.\footcite{CD}

\end{document}

• Ooops, you are right sorry, I didn't realise shortjournal was part of the default data model. Feb 17, 2019 at 11:18
• @moewe :-) And I was trying to grasp what you had in mind. As, in such issues, it is usually a matter of "how long" I take to agree with you, rather than "if". Feb 17, 2019 at 11:23
• @moewe I tried to incorporate the relevant information on how the source map works which was in your previous comment. I'm not sure I got it all though. Feb 17, 2019 at 12:11
• @moewe Btw, I did try the first solution with \iffieldannotation{shortened} (that is, without the optional argument [journaltitle]) and it didn't work. I have no idea why, as I would expect, from the documentation, that \currentfield would be grasped by the conditional. Feb 17, 2019 at 12:14
• I think that is due to the way the journaltitle field format is used: github.com/plk/biblatex/blob/… As you can see the format is not actually used to print a field (as in \printfield) instead it is used in a \printtext (which should have no \currentfield) to encompass several \printfields. (Of course you can't know that without looking at the code, that is the drawback of using field formats for both \printfield and \printtext and is made worse by using an actual field name as format name.) Feb 17, 2019 at 12:25