If we want to put an array in the caption of some table environment, we cannot do this (which causes an error)
\caption{A matrix here: $\begin{array}{lr} a & b \\ c & d \end{array}$}
Instead, we can put an array in the caption of some table environment as
\caption[]{A matrix here: $\begin{array}{lr} a & b \\ c & d \end{array}$}
which works with no error.
Question: What is the reason behind why putting [] in the \caption[] works? Thanks!
\protect\begin...
and\protect\end...
(and maybe\protect\\...
)..log
file (if your.tex
file ismain.tex
, openmain.log
) in a text editor and show me the first 10 lines or so.[]
works is when you have a List of Tables in your document. In that case the table caption needs to be written to this list, which is problematic for complex captions (for example containing anarray
environment). The optional argument between[]
is used to provide an alternative (usually shorter) caption for the List of Tables, i.e.,\caption[short title]{longer title}
. If the optional caption is provided then the complex caption does not need to be moved around and therefore does not cause any more trouble.