Certain macros or whole environments which are themselves not equations, like whole tikz diagrams can be placed in the equation environment and compile. For example Diagram displayed as an equation

Some other objects, like text generated by macros, apparently General way to split a line by a rule of thumb and displaying results, cause the equation environment to not compile. There are quite a few of them.

1) Is there some particular kind of macro (due to its structure or use of particular symbols...) that cannot be compiled inside an equation environment?

2) If a given macro does cause (1)-type problems, are there one or more environments (call them E*) which

a) each by itself can be (placed inside and) compiled inside the equation environment,

b) E* does not much change the output of what is placed inside of E*, and

c) E* can have a macro using symbols or structure (1) that crash the equation environment but not E* placed inside of it and then have E* placed inside the equation environment and compile?

[I observe generally that, for example, tikzpicture does compile always inside the equation environment for every (1)-type macro placed inside it but tikpicture is not a (2)-type environment, because the only thing printed in such cases inside the equation environment with the tikzpicture in it with the macro in it is an empty line that is numbered, so tikzpicture for example is a) and c) but not b) for obvious reasons. Does a (2)-type environment exist? I would imagine it would have to output an image which is treated as such and then loaded as a picture if the macros used otherwise do not compile inside the equation environment. Oh, yes, custom counters that replicate the equation functionality and center whatever is displayed are easy to make, and can replace equation mode, but journals typically dislike that sort of adhoc solution.]

  • 1
    A tikzpicture is basically something contained in a \mbox (\hbox if you want to go to a lower level); \mbox is always acceptable in math mode and the contents is typeset as if it were in normal text mode. – egreg Jul 14 '14 at 9:02

TeX has three main modes horizontal, vertical and math with math split into display and inline.

So the question is really what commands are allowed in display math.

Basically vertical mode commands are not allowed (with the exception of \halign, in the special case that it is the only thing in the display) so for example \begin{equation} \vskip2in produces ! Missing $ inserted.

horizontal and math mode commands are allowed with the exception of some strongly hbox related primitives such as \unhbox which gives the error ! Incompatible list can't be unboxed.

\par (a blank line) is not allowed in math.

Any vertical mode command can be included by first wrapping it in a vertical box (eg \parbox LaTeX macro.

Commands that start math mode may not be used in math mode. \begin{equation} $x$ is an error. ! Display math should end with $$.

Then there are commands that are not allowed because it is a group rather than because it is math \begin{equation}\egroup\end{equation} producing ! Extra }, or forgotten $.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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