0

I have a command which needs a math environment to be used. But sometimes I want to use it in a text environment and so, I need to create the math environment :

words words words \( \myFunction \) words words

How to detect in which environment I am ?

I want to be able to do :

words words words \myFunction words words

and

\( 1+2 = \myFunction \)
Ccile
  • 400
  • 4
    You might be looking for \ensuremath, see e.g. https://tex.stackexchange.com/questions/239585/how-can-i-write-a-macro-which-enters-math-mode-when-called-in-text-mode-but-when/239586#239586 and https://tex.stackexchange.com/questions/34830 – Torbjørn T. Jun 06 '17 at 10:06
  • The test, if you wish to test, is \ifmmode ...\else ...\fi – Steven B. Segletes Jun 06 '17 at 10:10

0 Answers0