TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want all displayed mathematics in my document to be typeset in the style of inline mathematics. In his answer to this question, Matthew Leingang explains how to do the opposite (typeset all inline mathematics in the style of displayed mathematics) by carefully modifying the \everymath token list. Reasoning by analogy I figured that the following test document ought to work:







But it does not. When trying to compile this document, TeXWorks gives the following error:

! Improper \halign inside $$'s.
<recently read> \halign

The code it displays, as though to draw my attention to a mistake, is the code in the vicinity of \end{align*}. This error does not appear if the line in the preamble modifying \everydisplay is commented out. Why doesn't this work?

share|improve this question
up vote 4 down vote accepted

Internall, align uses alignment displays, described p. 190 of the TeXbook as follows:

TeX also allows "alignment displays" [...] An alignment display is created by commands of the general form

$$ <assignments> \halign{ <alignment> } <assignments> $$

where the <assignments> [...] do not produce any math lists.

But \textstyle is not an assignment: in fact, it starts a math list. So \halign is not alone in that equation anymore, and TeX complains.

Now a solution: since align builds a construction like $\displaystyle ...$ internally, we can redefine the size using \let\displaystyle\textstyle.



An example of aligned equations,
\sum_{i=1}^N \frac{x^2}{2} + \frac{y^2}{2} &= \frac{\sqrt{z^{\frac{2}{3}}}}{2}
&\frac{\sqrt{z^{\frac{2}{3}}}}{2} &= \sum_{i=1}^N \frac{x^2}{2} + \frac{y^2}{2} 
\frac{\sqrt{z^{\frac{2}{3}}}}{2} &= \sum_{i=1}^N \frac{x^2}{2} + \frac{y^2}{2} 
&\sum_{i=1}^N \frac{x^2}{2} + \frac{y^2}{2} &= \frac{\sqrt{z^{\frac{2}{3}}}}{2}
which seem to work.

But the \verb|equation| environment won't:
\frac{\sqrt{z^{\frac{2}{3}}}}{2} = \sum_{i=1}^N \frac{x^2}{2} + \frac{y^2}{2} 


You might prefer saving the definition before using \let\olddisplaystyle\displaystyle in case you need it.

share|improve this answer
Ah, also a good idea. But can you explain why the code in the OP doesn't compile? – Hendrik Vogt Feb 23 '11 at 14:31
@Hendrik: I added something, but I'm not quite sure why alignment displays are useful, rather than just using an \halign outside a display. – Bruno Le Floch Feb 23 '11 at 15:08
Thanks! I wouldn't have guessed that reason. – Hendrik Vogt Feb 23 '11 at 15:13
Thank you very much for the explanation and the suggested workaround, much appreciated. – Hammerite Feb 23 '11 at 16:54

A partial workaround is to define some macros that can be used to replace the \[ ... \] and align* environments. Regard the following:





\blob{4^x + 5^y = 6^z \quad\mathrm{unless}\quad x = \frac{y}{z}}

    =\sum_{i=1}^{10} i^2 \nl
    \leq t^3 + \int_3^9y^a\,\mathrm{d}y


This gives displayed mathematics typeset as inline maths, and provides commands that do pretty much what I want and make for readable enough code. For unusual cases where \blob and \calc are not good enough, at least \t is reasonably concise, even if it does have to be just about everywhere.

This isn't a real answer to my question, though. I'd still like to know what the deal is with the original problem...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.