1

I use jabbrv with Biblatex to automatically abbreviate the journal titles in my reference list according to the ISO 4 standard.

I would like to have the titles of conference proceedings (i.e., the title field of @proceedings entries and the booktitle field of @inproceedings entries) similarly abbreviated, since they tend to be extremely wordy and formulaic (e.g., "Proceedings of the 53rd Annual Meeting of the Association for Computational Linguistics and the 7th International Joint Conference on Natural Language Processing" could be compressed to "Proc. 53rd Annu. Meet. Assoc. Comput. Linguist. 7th Int. Jt. Conf. on Nat. Lang. Process.").

Consider the following minimal example:

\documentclass{article}

\begin{filecontents}{\jobname.bib}
@inproceedings{foo,
  author = {John Smith},
  title = {International Linguistics is Fun},
  booktitle = {Proceedings of the 53rd {Annual} {Meeting} of the {Association} for {Computational} {Linguistics} and the 7th {International} {Joint} {Conference} on {Natural} {Language} {Processing}},
  year = 2015,
}

@inbook{bar,
  author = {Mary Taylor},
  title = {Some Chapter I Wrote},
  booktitle = {European Analytical Chemistry},
  year = 2022,
}
\end{filecontents}

\usepackage[backend=biber]{biblatex}
\addbibresource{\jobname.bib}
\usepackage{jabbrv}

% Variant 1
% \DeclareFieldInputHandler{booktitle}{\def\NewValue{\JournalTitle{#1}}}

% Variant 2
% \DeclareFieldFormat[inproceedings]{booktitle}{\JournalTitle{#1}}

\begin{document}
\nocite{*}\printbibliography
\end{document}

If I uncomment Variant 1, which is how the jabbrv package itself applies itself to journaltitle fields, then the @inproceedings entry's booktitle is correctly abbreviated. However, the @inbook entry's booktitle is also abbreviated (to "Eur. Anal. Chem."), which I don't want.

The jabbrv package source code includes a comment to the effect of

%% This package provides the "\JournalTitle{<title>}" command, where
%% "<title>" is a journal title that you wish to have automatically
%% abbreviated.  For example,
%%   \JournalTitle{Journal of the Optical Society of America}
%% will be replaced to read
%%   J. Opt. Soc. Am.

which leads me to believe that Variant 2 of my minimal example might work to constrain the abbreviation to only those booktitle fields in an @inproceedings entry. However, if I use this variant instead of Variant 1, the document fails to compile altogether:

ERROR: Missing \endcsname inserted.

--- TeX said ---
<to be read again> 
                   \let 
l.31 \end
         {document}
--- HELP ---
From the .log file...

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

Any ideas?

3 Answers 3

2

Perhaps surprisingly the \DeclareFieldFormat solution does not work, because \JournalTitle is a fairly complex macro that can essentially only work with raw text. The field format booktitle is not called on raw text, though, in the standard styles it is used as follows (biblatex.def, ll. 2849-3861 in v3.18)

\newbibmacro*{booktitle}{%
  \ifboolexpr{
    test {\iffieldundef{booktitle}}
    and
    test {\iffieldundef{booksubtitle}}
  }
    {}
    {\printtext[booktitle]{%
       \printfield[titlecase]{booktitle}%
       \setunit{\subtitlepunct}%
       \printfield[titlecase]{booksubtitle}}%
     \newunit}%
  \printfield{booktitleaddon}}

which means that the booktitle field format gets passed all of

\printfield[titlecase]{booktitle}%
\setunit{\subtitlepunct}%
\printfield[titlecase]{booksubtitle}%

on which \JournalTitle understandably chokes.


We can emulate a type-specific \DeclareFieldInputHandler with the use of \iffieldequalstr. While it is generally not guaranteed that the values of other fields are available when \DeclareFieldInputHandler is processed, the structure of the .bbl file ensures that the entry type can be checked (for all fields except entrykey and entrytype itself).

\documentclass{article}

\usepackage[backend=biber]{biblatex}
\usepackage{jabbrv}

\makeatletter
\DeclareFieldInputHandler{booktitle}{%
  \iffieldequalstr{entrytype}{inproceedings}
    {\def\NewValue{\JournalTitle{#1}}}
    {\def\NewValue{#1}}}
\makeatother

\begin{filecontents}{\jobname.bib}
@inproceedings{foo,
  author    = {John Smith},
  title     = {International Linguistics is Fun},
  booktitle = {Proceedings of the 53rd Annual Meeting
               of the Association for Computational Linguistics
               and the 7th International Joint Conference
               on Natural Language Processing},
  year      = 2015,
}
@inbook{bar,
  author    = {Mary Taylor},
  title     = {Some Chapter I Wrote},
  booktitle = {European Analytical Chemistry},
  year      = 2022,
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}\printbibliography
\end{document}

Proc. 53rd Annu. Meet. Assoc. for Comput. Linguist. 7th Int. Jt. Conf. on Nat. Lang. Process.
European Analytical Chemistry.


Another option would be to use source mapping to inject the \JournalTitle macro directly when Biber reads the data.

\documentclass{article}

\usepackage[backend=biber]{biblatex}
\usepackage{jabbrv}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \pertype{inproceedings}
      \step[fieldsource=booktitle,
         match=\regexp{\A(.*)\Z},
         replace=\regexp{\\JournalTitle{$1}}]
    }
  }
}

\begin{filecontents}{\jobname.bib}
@inproceedings{foo,
  author    = {John Smith},
  title     = {International Linguistics is Fun},
  booktitle = {Proceedings of the 53rd Annual Meeting
               of the Association for Computational Linguistics
               and the 7th International Joint Conference
               on Natural Language Processing},
  year      = 2015,
}
@inbook{bar,
  author    = {Mary Taylor},
  title     = {Some Chapter I Wrote},
  booktitle = {European Analytical Chemistry},
  year      = 2022,
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}\printbibliography
\end{document}
3
  • Thanks @moewe, this solution is very helpful and I will pass it on to others that encounter this issue. Yeah, \JournalTitle doesn't require the input to be exclusively text but it does require that the expanded input be exclusively text.
    – Compholio
    Sep 21 at 17:38
  • In the first solution is {\def\NewValue{#1}}} really required as the else branch? Couldn't one simply have an empty branch, {}?
    – Psychonaut
    Sep 22 at 8:36
  • @Psychonaut Yes, you could also leave the branch empty, because \def\NewValue{#1} is sort of "pre set".
    – moewe
    Sep 22 at 15:32
0

After playing around with things for a while, still not understanding why Variant 2 in my question doesn't work as expected, here's one solution I came up with. I'm not sure if it's the most elegant and so would welcome another answer that explains the cause of the original problem and (if necessary) provides a less convoluted solution.

% Variant 3
\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=booktitle]
      \step[fieldset=usera, origfieldval]
    }
  }
}
\DeclareFieldInputHandler{usera}{\def\NewValue{\JournalTitle{#1}}}
\DeclareFieldFormat[inproceedings]{booktitle}{\mkbibemph{\printfield{usera}}}

This variant uses a source map to copy the booktitle field to the usera field for all entries, then defines a field input handler on usera to wrap it in jabbrv's \JournalTitle command, and then finally defines the format for booktitle fields of @proceedings entries to print the usera field instead of the booktitle field.

0

The Biblatex folks might have a better solution, but you can replace the driver for inproceedings (key replacement emphasized with %):


\DeclareFieldFormat{abbrv}{\JournalTitle{#1}}
\DeclareBibliographyDriver{inproceedings}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{in:}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %\usebibmacro{maintitle+booktitle}%
  {\em\printfield[abbrv]{booktitle}}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \newunit\newblock
  \usebibmacro{event+venue+date}%
  \newunit\newblock
  \usebibmacro{byeditor+others}%
  \newunit\newblock
  \iffieldundef{maintitle}
    {\printfield{volume}%
     \printfield{part}}
    {}%
  \newunit
  \printfield{volumes}%
  \newunit\newblock
  \usebibmacro{series+number}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \printlist{organization}%
  \newunit
  \usebibmacro{publisher+location+date}%
  \newunit\newblock
  \usebibmacro{chapter+pages}%
  \newunit\newblock
  \iftoggle{bbx:isbn}
    {\printfield{isbn}}
    {}%
  \newunit\newblock
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}
2
  • {\em\printfield[abbrv]{booktitle}} could be replaced by just \printfield[abbrv]{booktitle} if we change \DeclareFieldFormat{abbrv}{\JournalTitle{#1}} to \DeclareFieldFormat{abbrv}{\mkbibemph{\JournalTitle{#1}}}. That said, \printfield[abbrv]{booktitle} does much less than the \usebibmacro{maintitle+booktitle}% it is replacing (for starters, the maintitle is ignored, plus the relevant ...subtitles), so the output needs to be checked carefully here.
    – moewe
    Sep 18 at 9:32
  • @moewe Yeah, it would be nice if I could find a solution that worked with \usebibmacro, since then you wouldn't need to do anything odd. However, I'm not finding a way to have it expand things properly such that something like "Variant 2" works correctly.
    – Compholio
    Sep 19 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.