简体   繁体   中英

LaTeX: cite with [ ] argument in caption

I need the source of images listed in the "list of figures". To do this I want to cite inside the caption argument:

This works:

\caption[Plan,\protect\cite{damluji1992}]{Plan}

This works too but i need it in the caption argument like in the next example:

\cite[p.156]{damluji1992}

I need this which doesn't work:

\caption[Plan,\protect\cite[p.156]{damluji1992}]{Plan}

it gives me the error "Argument of \HAR@dcite has an extra }." In the *.lof file the corresponding line looks like this:

\contentsline {figure}{\numberline {2}{\ignorespaces Plan, \cite [S.156}}{5}{figure.caption.4}

-> the cite argument in { } is missing!

Without the cite argument in [ ] it looks like this:

\contentsline {figure}{\numberline {2}{\ignorespaces Plan, \cite {damluji1992}}}{5}{figure.caption.4}

I stumbled on this page with the same question and then found the answer at http://www.latex-community.org/forum/viewtopic.php?f=50&t=6225

The solution: put curly braces around the cite command:

{\cite[Theorem~2]{mEtAl}}

The reason this is necessary is that you have an optional [] argument inside another optional [] argument.

In preamble:

\usepackage{caption}[2011/11/10]

\newcommand{\figsource}[1]{%
  \addtocounter{figure}{-1}
  \captionlistentry{source: #1}
 }

in document:

\begin{figure} 
  \includegraphics...
  \caption{whatever}
  \figsource{whatever-source}
\end{figure}

produces:

List of Figures

1.1 whatever. . . . . . . . 29

1.1 whatever-source: . . . . 29

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM