[OS X TeX] Re: "Runaway argument?" error in figure caption
Alan Munn
amunn at gmx.com
Tue Jul 17 20:47:57 EDT 2012
Hi John, you didn't actually try what I suggested. Notice that in my solution there are two arguments for the \caption command:
\caption[stuff for list of figures]{stuff for actual caption}
Sorry if I wasn't clear enough. As Manfred pointed out, the main problem was with fragile commands in moving arguments. The most common version of a moving argument is anything that gets written to the aux file. This is the case of captions, whose content is written to the aux file so that it can be used to create the list of figures or list of tables. Manfred's solution solves this by defining the matrix code as a macro and then using \protect to protect it from expansion when it's written to the aux file.
The solution I suggested requires you to put an alternative text not containing the fragile command into the moving part (the stuff that's for the list of figures) and then anything you like (including your original caption) into the caption part.
So you could have done
\caption[Vectors as arrows]{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.}
This would have put your caption where you wanted and written "Vectors as arrows" to the aux file. If you didn't have a list of figures at all, it would have sufficed to put
\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.}
I hope this is clearer now.
Alan
> Date: Tue, 17 Jul 2012 11:46:37 -0400 > From: "Alan Munn" <amunn at gmx.com> > > > [...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. <to be read again> \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. >> <to be read again> >> \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. >> (receives the digest version) ----------------------------------------------------------------------- "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>]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://email.esm.psu.edu/pipermail/macosx-tex/attachments/20120717/3fc4ee85/attachment.html>
More information about the MacOSX-TeX
mailing list