I'd like a macro that is the opposite of \ensuremath: something like \ensurenotmath, which makes sure that its argument is not typeset in math mode. Is there such a macro, or a way to implement it?
For my purposes, it would be sufficient to just detect math mode, so I could do something like:
\if\inmathmode
% give sensible error message
\else
% do the usual thing
\fi
Any ideas?
(Alternatively: I tried \show\ensuremath to see how it works, but it's protected. How can I use \show on such a macro?)
\protect\foowhere there is actually a space in the name\foo. You can use\expandafter\show\csname foo \endcsname--note the space after foo--to see the definition. – TH. Apr 07 '11 at 06:38\mbox{...}and the ... will be typeset in restricted horizontal mode, no matter what mode you're in outside the\mbox. – TH. Apr 07 '11 at 06:39\expandafterand\csname! – Dan Drake Apr 07 '11 at 07:01texdefscript:texdef -t latex ensuremath(orlatexdef ensuremathif thelatedefsymlink totexdefwas created). It detects the protected status automatically and also show the macro with the space. You can also use it explicitly:texdef -t latex 'ensuremath '– Martin Scharrer Apr 07 '11 at 07:39