[OS X TeX] Strange error

Morten Høgholm morten.hoegholm at gmail.com
Mon Nov 12 22:59:44 CET 2007


On Mon, 12 Nov 2007 21:45:59 +0100, Alain Schremmer wrote:

> or, at least, an error I don't understand.

It's never a good sign when you get those kinds of messages - especially  
not when you are doing something seemingly innocent...

> When I try to use align, say from the LaTeX panel, I get the following  
> console error:
>
> 	! Improper \halign inside $$'s.
> 	<recently read> \halign
>
> 	l.11 \end{align}
>
> 	?
>
> 1) I have reduced to the following minimal example:
>
> 		\documentclass[11pt]{book}
> 		\usepackage{lmodern}
> 		\usepackage{amsmath}
> 		\usepackage{fink}
> 		
> 		\begin{document}
> 			\begin{align}
> 	 		  1 &= 2  \\
> 			   3 &=  4
> 			\end{align}
> 		\end{document}

Below follows a fix which I would appreciate if you would forward to the  
package maintainer. But first, a little explanation as to how one might go  
about debugging this. Thanks for a good minimal example btw.

"! Improper \halign inside $$'s." means that TeX saw something to be  
typeset, i.e., not an assignment, in a place where it does not allow  
things to be typeset. So the question is: does anything special happen  
when processing this align? Yes! Because you are not using the default  
math fonts, they are loaded now because this is the first time LaTeX  
encounters math. And then something happens in fink.sty that apparently  
typesets something.

fink.sty is a rather small package and looks to contain only assignments  
but the definition of \fink at setnewfile is dangerous. It wants to put an  
operation into a group and succeeds at that, except when one uses {} in  
math mode, this creates an Ord atom. And since this is something to be  
typeset, TeX complains. Cure: use \begingroup \endgroup for grouping. Only  
ever use { } if something is supposed to be read as an argument or at the  
document level.


\documentclass[11pt]{book}
\usepackage{mathpazo}% or anything else changing math fonts
\usepackage{amsmath}
\usepackage{fink}

\makeatletter

% Original
% \def\fink at setnewfile#1{%
%   {\filename at parse{#1}%
%     \xdef\@finkfile{%
%       \filename at base.\ifx\filename at ext\relax tex\else\filename at ext\fi}}}

% Fixed version.
\def\fink at setnewfile#1{%
   \begingroup
   \filename at parse{#1}%
     \xdef\@finkfile{%
       \filename at base.\ifx\filename at ext\relax tex\else\filename at ext\fi}%
   \endgroup}

\makeatother

\begin{document}

\begin{align}
   1 &= 2  \\
   3 &=  4
\end{align}

\end{document}
-- 
Morten



More information about the macostex-archives mailing list