Possible Duplicate:
Is there a test for the different styles inside maths mode?
This is my first post here, so I can't promise to get all formatting right, but I'll try.
Consider the following macro:
\def\modes{{\bf \ifmmode\ifinner IM\else MM\fi\else TM\fi}}
According to both the 'TeXbook' and 'TeX for the Impatient' the \ifinner macro should 'True if TeX is in [...] (nondisplay) math mode [...]' (page 209 in the TeXbook). The 'TeX for the Impatient' does not print the braces surrounding 'nondisplay', so when writing in a document:
\modes - $\modes$
\[
\modes
\]
I'm kind of expecting to get:
TM - IM
MM
However, the result is:
TM - IM
IM
I guess the TeXbook has slightly more authority, yet to me it sounds reasonable that indeed I should get the expected result. So I guess my question boils down to the following:
Am I misunderstanding the explanation of \ifinner in the TexBook
- if yes, then how to achieve the result I'm looking for?
- if no, what could be wrong then? Both pdfTeX and LaTeX produce this result, I'm running pdfTeX/LaTeX using libpoppler 3.141592-1.40.3-2.2 on Linux.
Thanks in advance.
\ifinneris true in a subformula. – egreg May 09 '12 at 12:36\ifinneris true in nondisplay math mode but doesn't say it's false in display math mode. TeX by Topic is wrong on p. 201 where it says that\ifinneris not true in display math mode. – egreg May 09 '12 at 14:41\ifinneris also true inside a tabular environment (\halign) – Danie Els May 09 '12 at 15:26\leftand\rightin front of (any) braces whenever the formula would appear in display math mode, but not elsewhere. The other question and answers made me realize that I would actually loose all control over braces, so I just created a macro that always scales, except when I call a 'starred' version. That way I'm more in control, which I like. – Jakob van Bethlehem May 14 '12 at 13:43