4

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.

  • 3
    See this question that might help you. Actually \ifinner is true in a subformula. – egreg May 09 '12 at 12:36
  • Actually the TeXbook says that \ifinner is 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 \ifinner is not true in display math mode. – egreg May 09 '12 at 14:41
  • Note that \ifinner is also true inside a tabular environment (\halign) – Danie Els May 09 '12 at 15:26
  • Thanks everyone for the responses. In the end the question egreg pointed at, hinted at the right solution. In the end, what I wanted is a macro that would put \left and \right in 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

0 Answers0