4

I want to create citations for my figures, and make the citation only appear in the list of figures as a short citation (if it wasn't cited before then it should be added to the normal \printbibliography output as well). Generally that works fine.

However in my document if a bibliography entry wasn't cited before in normal text, it won't print the proper citation (nor does it get added to the bibliography), but only the label (?!) of the bibliography entry in bold. I can cite it before in normal text inside a \phantom enviroment to avoid this, but that's definitely not a nice solution.

In a MWE it works fine... maybe there is something in my document I overlooked, but the common demoninator of all the cases where the label is printed instead of the citation, is the fact that they all are cited for the first time in the document (they also all have the type online).

\documentclass{article}
\usepackage{graphicx}
\usepackage[backend=biber,style=verbose-ibid,hyperref=false]{biblatex}
\addbibresource{mwe.bib}

\newbibmacro*{shrtcite}{%
  \usebibmacro{cite:citepages}%
  \iffieldundef{shorthand}
    {\usebibmacro{cite:short}}
    {\usebibmacro{cite:shorthand}}}

\DeclareCiteCommand{\shrtcite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{shrtcite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}


\begin{filecontents}{mwe.bib}
@Book{knuth1986,
    Title                    = {The \TeX book},
    Author                   = {Donald~Ervin Knuth},
    Publisher                = {Addison-Wesley},
    Year                     = {1986}
}
\end{filecontents}

\begin{document}

\begin{figure}
    \centering
    \includegraphics[scale=0.2]{example-image-a}
    \caption[{\shrtcite[][5]{knuth1986}}]{This is a caption}
\end{figure}

\printbibliography
\listoffigures
\end{document}

It seems rather weird to me, if anyone knows a generally different and better approach to my original goal (citations for figures only appearing in listoffigures), please help me out.

1 Answer 1

3

biblatex explicitly disables the so-called "cite request" in the table of contents, list of figures and list of tables. That means that when an item is cited there, this citation is not logged in the .bcf and .aux files. Usually that is desired because it avoids the issue with numeric styles and sorting=none (unsrt in BibTeX) that a citation gets a lower number than one might expect just because it appears in the table of contents or list of figures (Ignore citations in captions in list of figures when numbering). Usually text that is sent to the ToC, LoF, LoT is typeset somewhere else again and at that point the cite request would be logged.

If you cite particular entries only in the optional argument of \caption that citation will only be typeset in the LoF/LoT and thus only in a context where cite requests are not honoured.

So this is sort of expected behaviour and certainly not something that can change. I'm afraid you will have to manually send the cite request off. This is usually done with \nocite (outside the optional argument of \caption), e.g.

\caption[{\shrtcite[][5]{knuth1986}}]{This is a caption}\nocite{knuth1986}

but you can wrap that up in a handy command to make it less painful.

\documentclass{article}
\usepackage{graphicx}
\usepackage[backend=biber,style=verbose-ibid,hyperref=false]{biblatex}

\newbibmacro*{shrtcite}{%
  \usebibmacro{cite:citepages}%
  \iffieldundef{shorthand}
    {\usebibmacro{cite:short}}
    {\usebibmacro{cite:shorthand}}}

\DeclareCiteCommand{\shrtcite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{shrtcite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\newcommand*{\captioncite}[3][]{%
  \caption[{\shrtcite[][#1]{#2}}]{#3}\nocite{#2}}

\addbibresource{biblatex-examples.bib}

\begin{document}
\begin{figure}
    \centering
    \includegraphics[scale=0.2]{example-image-a}
    \captioncite[5]{sigfridsson}{A caption}
\end{figure}

\printbibliography
\listoffigures
\end{document}

Working citation in LoF and bibliography


If you always use \shrtcite (only) in this context, you could alternatively let \shrtcite turn the cite request back on for you. This can't be done with the usual idiom of adding the boolean to the precode (because the precode is only executed if the citation data is available, but the citation data is only available if the cite request succeeds), so we have to find another way and get it in via the wrapper format.

\documentclass{article}
\usepackage{graphicx}
\usepackage[backend=biber,style=verbose-ibid,hyperref=false]{biblatex}

\newbibmacro*{shrtcite}{%
  \usebibmacro{cite:citepages}%
  \iffieldundef{shorthand}
    {\usebibmacro{cite:short}}
    {\usebibmacro{cite:shorthand}}}

\newrobustcmd*{\mkciterequesttrue}[1]{{\booltrue{citerequest}#1}}

\DeclareCiteCommand{\shrtcite}[\mkciterequesttrue]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{shrtcite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\addbibresource{biblatex-examples.bib}

\begin{document}
\begin{figure}
    \centering
    \includegraphics[scale=0.2]{example-image-a}
    \caption[{\shrtcite[5]{sigfridsson}}]{A caption}
\end{figure}

\printbibliography
\listoffigures
\end{document}

The MWE you posted in https://tex.stackexchange.com/revisions/541549/3 with two citations unearthed a very obscure bug in biblatex related to disabling the "cite request" that should be fixed in the next biblatex release (https://github.com/plk/biblatex/commit/a821b82a76f34c24eac1225b2c5208c71c87081a). That bug does not change the underlying issue we are facing here and does not impact on the workaround presented here.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .