[OS X TeX] Missing $ inserted in a "variations" environment

Jonathan Kew jonathan at jfkew.plus.com
Sun Mar 15 13:39:47 EDT 2009


On 15 Mar 2009, at 14:09, <ewan.Delanoy at math.unicaen.fr> <ewan.Delanoy at math.unicaen.fr 
 > wrote:

>                   Hello all,
>
>
>   I've just encountered the following problem with TeXShop :

You're having a problem with LaTeX, not with TeXShop. It would be  
useful to learn something about the distinction.

>
>  1) Compilation stops with the error message "Missing $ inserted".
>  2) If I insist and press "Enter" twice in the console, it eventually
> compiles completely
> and produces a fine output.

Not quite. Look at the first minus-infinity at the bottom; it'll have  
a hyphen instead of a minus sign.

>
>  3) By trial and error, I see that what causes this behaviour is a
> "variations" array
> (from the variations package) in the middle of my text.
>  3) The line number displayed in the error message, l.259, is not very
> illuminating
> because the source text is as follows

This is presumably because none of the content of the {variations}  
environment actually gets processed until the end reached.

>
> \noindent \makebox[\textwidth][c]{
> \begin{variations}
>   x  & \mI  &   & \alpha& & & 1 & & \beta&  & & 2 & & \pI & \\
>   \filet
> f'(x) & \bg & + & \bb&  & + & \z & -& \bb & & - &\z& + & &\bd \\
> \filet
>  \m{f(x)} & \bg \mI &  \c \h{\pI} & \bb& \mI & \c & \h{-1} & \d \mI  
> & \bb
> & \h{\pI}& \d &\frac{3}{2}& \c
>  & \h{\pI} & \bd \\
> \end{variations}
> }<- Line 259 is here
>
> Can anyone help me on this ?

One way to locate the problem more precisely, if you don't notice the  
incorrect minus sign at first, is to type "i XXXX" in response to the  
error message instead of just hitting Enter. You'll see the inserted  
XXXX in your output and this may help you spot where things are going  
wrong.

It seems that {variations} is automatically putting each "cell" of the  
table it creates into math mode, probably using an \halign template.  
But the \bg command, besides creating an extra rule on the left, also  
cancels the alignment template for the current entry (\show\bg  
indicates that its expansion  begins with \omit). So where you have  
"....& \bg \mI &...." the automatic math mode does not apply, and  
hence you get an error when you try to use the infinity symbol.

You can remove the error by adding $...$ around \mI in this case, but  
(a) it seems ugly to have to do this, when other cells are  
automatically in math mode; and (b) this results in extra space  
between the symbol and the following arrow. So it's not really very  
satisfactory.

It looks like what you should really do is split off the border you're  
creating with \bg into a separate column of the table, as the  
{variations} environment doesn't know how to combine this nicely with  
math-mode content. Thus:

	\noindent \makebox[\textwidth][c]{
	\begin{variations}
	x & & \mI & & \alpha& & & 1 & & \beta& & & 2 & & \pI & \\
	\filet
	f'(x) & \bg & & + & \bb& & + & \z & -& \bb & & - &\z& + & &\bd \\
	\filet
	\m{f(x)} & \bg & \mI & \c \h{\pI} & \bb& \mI & \c & \h{-1} & \d \mI &  
\bb
	& \h{\pI}& \d &\frac{3}{2}& \c
	& \h{\pI} & \bd \\
	\end{variations}
	}

HTH,  JK




More information about the MacOSX-TeX mailing list