[Tex/LaTex] Error when using \cite with page number in short caption of table

biblatexcaptionstables

when using the \cite command with a page number in the short caption of a table or figure along with the command \listoftables, I keep getting the following set of error messages:

./Test_Bibtex.lot:3: Argument of \blx@citeargs@i has an extra }.
<inserted text> 
                \par 
l.3 ...{\ignorespaces Short caption (\cite [5}}{1}

Runaway argument?
5
./Test_Bibtex.lot:3: Paragraph ended before \blx@citeargs@i was complete.
<to be read again> 
                   \par 
l.3 ...{\ignorespaces Short caption (\cite [5}}{1}

Quite obviously, there seems to be problem that has to do with the parsing of the page number in the .lot file.

Here you can see a MWE where the first \caption command creates the error as it contains a page number, while the second (commented) one works alright:

\documentclass{article}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@book{Geertz:1973,
    Address = {New York},
    Author = {Geertz, Clifford},
    Date-Added = {2013-08-09 17:17:10 +0000},
    Date-Modified = {2013-08-09 17:18:06 +0000},
    Publisher = {Basic Books},
    Title = {The Interpretation of Cultures. Selected essays},
    Year = {1973}}
\end{filecontents}

\usepackage[style=authoryear, useprefix=true, language=english]{biblatex}
\bibliography{\jobname}

\begin{document}
\listoftables

\begin{table}[hbtp]
\centering
  \begin{tabular}{ll}
    \hline
    w&x\\
    \hline
    y&z\\
    \hline\\
  \end{tabular}
  \caption[Short caption (\cite[5]{Geertz:1973})]{A longish caption of the table, inspired by \textcite[5]{Geertz:1973}} % creates the problem, due to the page number
  %\caption[Short caption (\cite{Geertz:1973})]{A longish caption of the table, inspired by \textcite{Geertz:1973}} % works, as there is no page number
\end{table}

\end{document}

Any suggestions on how to get this to work?

Thank you in advance!

Thomas

Best Answer

When using a command with optional arguments in the optional argument of another command one must protect the inner ] by putting {...} around the inner command so that TeX doesn't think it ends the outer argument (TeX doesn't check the nesting of such [..] braces as it would do for {..})

  \caption[Short caption ({\cite[5]{Geertz:1973}})]{A longish caption ...} 

There are lots of similar questions around:

Optional argument within another optional argument in biblatex \cite

Macro with optional arguments into arguments of another macro

Related Question