4

I'd like to define a command \Lm, such that if used in a maths environment it is replaced with \mathcal{L}, but when used outside of the maths environment it would be replaced with $\mathcal{L}$. This would allow me to write both a sentence like this:

$\langle \Lm, \R \rangle$ is a \emph{deductive system}
consisting of a language \Lm and a set of inference rules \R;

I know how to write either of those behaviours separately: \newcommand{\Lm}{$\mathcal{L}$}, \newcommand{\Lm}{\mathcal{L}}, but I'm not sure if there is a way to decide which one to use based on the environment I'm in.

1
  • 5
    I'd recommend writing consisting of a language $\Lm$ and .... The symbol is math, after all; you gain little in not properly segregating math as math.
    – egreg
    Commented May 23, 2013 at 14:38

1 Answer 1

8

For this specific problem, you can define your command as

\newcommand{\Lm}{\ensuremath{\mathcal{L}}}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .