I would like to define a command which displays some formula in a different way,
depending on whether it is used in math mode or in display mode. How do I do that?
Thanks for any suggestions.
General ⇒ Different command definition in math mode and display mode
Different command definition in math mode and display mode
Last edited by szymtor on Sun Feb 27, 2011 2:06 pm, edited 1 time in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.

-
- Site Moderator
- Posts: 814
- Joined: Tue Jul 01, 2008 2:19 pm
Different command definition in math mode and display mode
The TeX \mathchoice primitive is the best way to do this:
Code: Select all
\mathchoice{<display mode>}{<text mode>}{<superscript mode>}{<supersuperscript mode>}
Joseph Wright
Re: Different command definition in math mode and display mo
Very cool. Thanks!
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Different command definition in math mode and display mode
Then please mark the topic (not the last post) accordingly as written in Section 3 of the Board Rules (to be read before posting).szymtor wrote:Very cool. […]
Best regards and welcome to the board
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10