Text Formatting ⇒ How can I know if I am in mathematic enviroment?
How can I know if I am in mathematic enviroment?
How can I know if I am in mathematic enviroment?
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
How can I know if I am in mathematic enviroment?
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
Re: How can I know if I am in mathematic enviroment?
localghost
I need to know about it in program mode. I want to write some commands, which can do other acting, depending on if we it in mathematical environment.
For example
newcommand{\ex}
{\ifthenelse{"the command is called in math mode"}{act1}{act2}}
\[
...
\ex % do act1
...
\]
\ex % do act2
I need to know about it in program mode. I want to write some commands, which can do other acting, depending on if we it in mathematical environment.
For example
newcommand{\ex}
{\ifthenelse{"the command is called in math mode"}{act1}{act2}}
\[
...
\ex % do act1
...
\]
\ex % do act2
-
- Site Moderator
- Posts: 814
- Joined: Tue Jul 01, 2008 2:19 pm
Re: How can I know if I am in mathematic enviroment?
TeX has the primitive \ifmmode. You will need to be careful using this with ifthenelse. If you can give a complete example of what you want to achieve, it might help.
Joseph Wright
Re: How can I know if I am in mathematic enviroment?
josephwrightThanks..
\newcommand{\rv}{\text{В}}
\newcommand{\ra}{\text{А}}
\newcommand{\rma}{\text{мА}}
\newcommand{\rom}{\text{Ом}}
\newcommand{\rvt}{\text{Вт}}
\newcommand{\rkHz}{\text{кГц}}
In \text{} Russian units of measurement. If I amn't in math mode, i should use it without \text command.
\newcommand{\rv}{\text{В}}
\newcommand{\ra}{\text{А}}
\newcommand{\rma}{\text{мА}}
\newcommand{\rom}{\text{Ом}}
\newcommand{\rvt}{\text{Вт}}
\newcommand{\rkHz}{\text{кГц}}
In \text{} Russian units of measurement. If I amn't in math mode, i should use it without \text command.