I'm trying to use German umlauts in math mode but get the known error: LaTeX Warning: Command \" invalid in math mode on input line ##.
So I could think of two possible solutions:
- Use
\textinstead of\mathrm. But this wouldn't be the right solution because this text will be changed according to the surrounding text and the text I try to write ("Empfänger", German word for "receiver") should appear as a superscript to a field variable. - Replace the letter
äwith"a. But this leads to LaTeX not recognizing the ligature offä.
Since I'm using the lmodern package, the letter ä is still shown, so the resulting PDF is what I would expect.
Are there some elegant and correct solutions to this merely cosmetic problem?
My code for this would be:
\documentclass{scrartcl} % Kodierung \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{lmodern} % Sprache (neue deutsche Rechtschreibung) \usepackage[ngerman]{babel} % Mathematik \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \begin{document} % reference Empfänger % creates warning but is correct \begin{align} \mathrm{Empfänger} \end{align} % creates no warning but has no ligature \begin{align} \mathrm{Empf"anger} \end{align} \end{document} 
\mathrm{Empf"anger}, try writing\text{Empf"anger}. The\textcommand, incidentally, is provided by theamsmathpackage, which you're already loading.\textrm) in math mode. I don't post it as an answer because I don't know if it is best practice."aexpands to\ddot ain math mode.\textbut probably you are looking for\text{\normalfont Empfänger}.