Is it somehow possible to put a citation including page specification, as in \cite[page]{book}
, inside the list-of-figures-relevant caption of a figure, i.e. \caption[*HERE*]{...}
?
I can do
\caption[\protect\cite{book}]{other text}
but
\caption[\protect\cite[page]{book}]{other text}
yields book] other text
as the caption in the first run and produces an error "Argument of \NAT@@cite has an extra }" in the second LaTeX run.
I'm using pdfLaTeX and natbib.
Best Answer
The scanning of an optional argument (in brackets,
[
and]
) works in a slight different way than the scanning of a mandatory argument (in braces,{
and}
); TeX counts the braces, but doesn't do the same for brackets. So, with your input, the optional argument that is seen isthat is, everything from
[
to the first]
(which is balanced with respect to braces). In order to avoid this problem, brackets inside an optional argument must be "masked" with braces:The argument cannot have unbalanced braces, so the bracket after
page
doesn't end it, in this case.