[OS X TeX] Re: "Runaway argument?" error in figure caption

John B. Thoo jthoo at yccd.edu
Tue Jul 17 19:34:17 EDT 2012

Thanks to Z[bigniew] N, Manfred B, and Alan M for their replies.  Below are my results following their suggestions.

On Jul 17, 2012, at 12:00 PM, <macosx-tex-request at email.esm.psu.edu> wrote:

> Date: Tue, 17 Jul 2012 14:10:40 +0000
> From: "Nitecki, Zbigniew H." <Zbigniew.Nitecki at tufts.edu>
>
> Your "begin" and "end" don't match (\begin{smalltrix}.\end{small matrix})

Oops ... that was a typo, but thankfully not inside the code. :-)  Thanks.

> Date: Tue, 17 Jul 2012 17:52:59 +0300
> From: Manfred Braun <manfred.braun at uni-due.de>
>
> Within a caption the use of commands and environments is restricted.  Commands must be "protected".  A possible solution is as follows:  Define, for instance,
>
> \newcommand\mymatrix{ \left[ \begin{smallmatrix} 3 \\ 4 \end{smallmatrix} \right] }
>
> in the preamble.  Then replace your caption by
>
> \caption{It is useful to picture vectors as arrows, although this may not be a literal representation of vectors.  Here we identify the vector $\vec{u} = \protect\mymatrix$ in $\R{2}$ represented as an arrow with the point $(3,4)$ in the $xy$ plane.}
>
> This should work.  Important is to include the \protect command.  It prevents the immediate expansion of the subsequent \mymatrix command, the expansion is postponed until the caption is typeset.

Yes, that worked! :-)  Thanks.

> Date: Tue, 17 Jul 2012 11:46:37 -0400
> From: "Alan Munn" <amunn at gmx.com>
>
> A possible solution is as follows: Define, for instance, \newcommand\mymatrix{ \left[ \begin{smallmatrix} 3 \\ 4 \end{smallmatrix} \right] } in the preamble. Then replace your caption by \caption{It is useful to picture vectors as arrows, although this may not be a literal representation of vectors. Here we identify the vector $\vec{u} = \protect\mymatrix$ in $\R{2}$ represented as an arrow with the point $(3,4)$ in the $xy$ plane.} This should work.
>
> [...snip, snip...]
>
> Alternatively, you can load the caption package and provide an alternative title for the caption to be used in the list of figures:
>
> \usepackage{caption}
>
> \begin{figure}
> ...
> \captionsetup{singlelinecheck=off}
> \caption[stuff for list of figures]{stuff for the actual caption}
> \end{figure}

I tried that

\captionsetup{singlelinecheck=off}
\caption{It is useful to picture vectors as arrows, although this may not be a literal representation of vectors.  Here we identify the vector $\vec{u} = \left[\begin{smallmatrix} 3 \\ 4 \end{smallmatrix}\right]$ in $\R{2}$ represented as an arrow with the point $(3,4)$ in 2-dimensional Euclidean space, that is, in the $xy$ plane.}

but still got the error

[5]
! Argument of \@caption has an extra }.
<inserted text>
\par
l.178 ...idean space, that is, in the $xy$ plane.}

?
Runaway argument?
\@captype {\def \@currenvir {smallmatrix}\edef \@currenvline {\on at line \ETC.
! Paragraph ended before \@caption was complete.
\par
l.178 ...idean space, that is, in the $xy$ plane.}

?
[6]

But now I know about the caption package. :-)  Thanks.

---John.

>> Date: Tue, 17 Jul 2012 06:38:25 -0700
>> From: "John B. Thoo" <jthoo at yccd.edu>
>> Subject: [OS X TeX] "Runaway argument?" error in figure caption
>>
>> Hi, everyone.  I apologize that this is not a Mac-specific question, but rather a general LaTeX question; however, I don't know whom else to ask.
>>
>> This code
>>
>> \begin{figure}
>> \begin{tikzpicture}
>> \pgftransformscale{0.75}
>> %% axes
>>  \draw[help lines,lightgray] (-1,-1) grid (5,5);
>>  \draw[thin] (-1,0) -- (5,0) node[anchor=north]{$x$};
>>  \draw[thin] (0,-1) -- (0,5) node[anchor=west]{$y$};
>> %% u and (u1,u2)
>>  \draw[thick,-latex] (0,0) -- (3,4);
>>    \draw (1.6,2) node[anchor=west]{$\vec{u} = \left[\begin{array}{c} 3 \\ 4 \end{array}\right]$};
>>  \fill (3,4) circle (0.08) node[anchor=west]{$(3,4)$};
>> \end{tikzpicture}
>>  \caption{It is useful to picture vectors as arrows, although this may not be a literal representation of vectors.  Here we identify the vector $\vec{u} = \left[\begin{smallmatrix} 3 \\ 4 \end{smallmatrix}\right]$ in $\R{2}$ represented as an arrow with the point $(3,4)$ in the $xy$ plane.}
>>  \label{fig.syslineqns:vectorasarrow}
>> \end{figure}
>>
>> produces this error
>>
>> [5]
>> ! Argument of \@caption has an extra }.
>> <inserted text>
>>                \par
>> l.177 ...ith the point $(3,4)$ in the $xy$ plane.}
>>
>> ?
>> Runaway argument?
>> \@captype {\def \@currenvir {smallmatrix}\edef \@currenvline {\on at line \ETC.
>> ! Paragraph ended before \@caption was complete.
>>                   \par
>> l.177 ...ith the point $(3,4)$ in the $xy$ plane.}
>>
>> ?
>>
>> Overfull \hbox (73.62pt too wide) in paragraph at lines 217--249
>> []$[]$
>> [6] [7]
>>
>>
>> The figure and caption appear to typeset OK, though.  I think the error is because of the  \begin{smalltrix}...\end{smallmatrix},  but I don't know how to fix it.
>>
>> Any suggestions?  I am using TeX-Live 2009 that I typeset using pdflatex in an xterm window and view using Preview.  My OS is Lion.
>>
>> Thanks very much.
>>
>> ---John.

-----------------------------------------------------------------------
"Ten thousand difficulties do not make one doubt....  A man may be annoyed that he cannot work out a mathematical problem ... without doubting that it admits an answer."

---John Henry Newman [_Apologia_, p. 239 in Project Gutenberg's
<http://www.gutenberg.org/ebooks/22088>]