3

I have a lot of figures that I'm referring to and I prefer to give short cites for the list of figures, ie without the source, unfortunately when I have to fix a typo etc. I need to change the short- as well as the full-caption. Is there a good way to name the figure just once? (maybe with a variable that contains the short-caption, in the document or is there maybe a more elegant way?)

\documentclass{article}

\usepackage[backend=biber]{biblatex}
\usepackage{caption}
\usepackage[demo]{graphicx}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
    @article{A01,
        author = {Albert Einstein},
        title = {the true about tree},
        journaltitle = {Annalen der Physik},
        year = {1905},
        volume = {322},
        number = {10},
        pages = {891--921}
    }
\end{filecontents}
\addbibresource{\jobname.bib}

\newtoks\shortcap
\shortcap={foo bar baz}


\begin{document}

\listoffigures  


\begin{figure}
\centering
\includegraphics[width=3.0in]{example-image-a}
\shortcap={Some Text}
\caption[\the\shortcap]{\the\shortcap, Source:~\cite{A01}}
\end{figure}


\end{document}
3
  • 1
    One idea is to use a wrapper which grabs the arguments designed for \caption and checks whether there is \cite at all.
    – user31729
    Commented Aug 5, 2015 at 13:04
  • How about notoccite instead of reinventing the wheel?
    – Johannes_B
    Commented Aug 5, 2015 at 13:05
  • notoccite seems to be a good idea unfortunately sometimes I have to write ",based on [A01]" and I suppose notice doesn't work in this case.
    – jlk
    Commented Aug 5, 2015 at 13:11

2 Answers 2

5

I'd go the opposite way; defining a different command allows using the original one for tough cases.

\begin{filecontents}{\jobname.bib}
    @article{A01,
        author = {Albert Einstein},
        title = {the true about tree},
        journaltitle = {Annalen der Physik},
        year = {1905},
        volume = {322},
        number = {10},
        pages = {891--921}
    }
\end{filecontents}

\documentclass{article}

\usepackage[backend=biber]{biblatex}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{xparse}

\addbibresource{\jobname.bib}

\NewDocumentCommand{\Caption}{om}{%
  \IfNoValueTF{#1}
    {\caption{#2}}
    {\caption[#2]{#2. Source:~\cite{#1}}}%
}

\begin{document}

\listoffigures  


\begin{figure}[htp]
\centering
\includegraphics[width=3.0in]{example-image-a}
\Caption[A01]{Some text}
\end{figure}

\begin{figure}[htp]
\centering
\includegraphics[width=3.0in]{example-image-b}
\Caption{Some text}
\end{figure}

\end{document}

enter image description here

A different approach, where you add the full final text.

\begin{filecontents}{\jobname.bib}
    @article{A01,
        author = {Albert Einstein},
        title = {the true about tree},
        journaltitle = {Annalen der Physik},
        year = {1905},
        volume = {322},
        number = {10},
        pages = {891--921}
    }
\end{filecontents}

\documentclass{article}

\usepackage[backend=biber]{biblatex}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{xparse}

\addbibresource{\jobname.bib}

\NewDocumentCommand{\sourcecaption}{omm}{%
  \IfNoValueTF{#1}
    {\caption[#2]{#2#3}}
    {\caption[#1]{#2#3}}%
}

\begin{document}

\listoffigures  


\begin{figure}[htp]
\centering
\includegraphics[width=3.0in]{example-image-a}
\sourcecaption{Some text}{. Source:~\cite{A01}}
\end{figure}

\begin{figure}[htp]
\centering
\includegraphics[width=3.0in]{example-image-b}
\sourcecaption[Some short text]{Some very long text}{, based on~\cite{A01}}
\end{figure}

\end{document}

enter image description here

2
  • Thanks you very much, is it possible the change it to be a bit more flexible, ie. means to handle, the following scenarios. caption(Some Text~\cite[A01]) and caption(Some Text, based on~\cite[A01])?
    – jlk
    Commented Aug 5, 2015 at 13:29
  • @harryhaller I added a different version
    – egreg
    Commented Aug 5, 2015 at 13:41
1

You could also use a specific cite command which disappears in the lof:

\documentclass{article}

\usepackage[backend=biber]{biblatex}
\usepackage{caption}
\addbibresource{biblatex-examples.bib}

\newbool{showcites}
\DeclareCiteCommand\hiddencite{}{}{}{}
\DeclareRobustCommand\nottoccite[1][Source:~]{\ifbool{showcites}{#1\cite}{\hiddencite}}


\begin{document}

\boolfalse{showcites}
\listoffigures
\booltrue{showcites}

\begin{figure}
\centering
blub
\caption{blalbl 
 \nottoccite{shore}%
 \nottoccite[, ][50]{aksin}%
 \nottoccite[, and based on~][Vol][3]{herrmann}}
\end{figure}


\end{document}

But I don't like the fiddling with the commas and the text, so in the long run I would probably simply use a generic command to let text disappear in the lof:

\documentclass{article}

\usepackage[backend=biber]{biblatex}
\usepackage{caption}
\addbibresource{biblatex-examples.bib}

\newbool{show}
\DeclareRobustCommand\notintoc[1]{\ifbool{show}{#1}{}}


\begin{document}

\boolfalse{show}
\listoffigures
\booltrue{show}

\begin{figure}
\centering
blub
\caption{blalbl 
\notintoc{Source:~\cite{shore}, \cite[50]{aksin}, and based on \cite[Vol][3]{herrmann}}}
\end{figure}


\end{document}

enter image description here

You must log in to answer this question.

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