Text Formatting ⇒ How can I know if I am in mathematic enviroment?
How can I know if I am in mathematic enviroment?
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
How can I know if I am in mathematic enviroment?
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: How can I know if I am in mathematic enviroment?
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
-
josephwright
- Site Moderator
- Posts: 814
- Joined: Tue Jul 01, 2008 2:19 pm
Re: How can I know if I am in mathematic enviroment?
Re: How can I know if I am in mathematic enviroment?
\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.