# Umlauts in math mode

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:

1. Use \text instead 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.
2. Replace the letter ä with "a. But this leads to LaTeX not recognizing the ligature of fä.

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}

-
Welcome to TeX.SE! Instead of \mathrm{Empf"anger}, try writing \text{Empf"anger}. The \text command, incidentally, is provided by the amsmath package, which you're already loading. –  Mico Feb 13 '13 at 14:48
You can use the text formatting commands (in your case, you need \textrm) in math mode. I don't post it as an answer because I don't know if it is best practice. –  T. Verron Feb 13 '13 at 14:49
Side note: "a expands to \ddot a in math mode. –  Qrrbrbirlbel Feb 13 '13 at 14:50
I don't exactly why you don't want to use \text but probably you are looking for \text{\normalfont Empfänger}. –  Ulrike Fischer Feb 13 '13 at 14:50
@UlrikeFischer : As I understand it, the text is supposed to be part of a notation. You don't want a notation to be different depending on whether you're in a theorem or a proof. –  T. Verron Feb 13 '13 at 14:54

As you load the ams packages, you can use \textnormal:

\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}

Test
\begin{align}$$\textnormal{Empf"anger}$$\end{align}
test

\itshape Test
$$\textnormal{Empf"anger}$$
test

\end{document}


As the example shows, this is immune to the surounding text changes.

-
You don't need ams to use it: \textnormal is defined in the latex kernel. –  Ulrike Fischer Feb 13 '13 at 15:12
@UlrikeFischer True, but with ams it will resize appropriately in sub- and suprescripts too. –  Andrew Swann Feb 13 '13 at 15:37

Instead of using \mathrm you should use \text to write text in a math environment. That should not have any problems with umlauts.

-
If the text around the equation is italics (e.g. a theorem), \text will print the text as italics too. –  T. Verron Feb 13 '13 at 14:49

Maybe not the most elegant solution, but definitely package-independent is to define a new command:

\newcommand{\aumlaut}{\text{\textit{\"a}}}


If you have inputenc with UTF-8 for instance, you could of course have ä straightaway.

-
This only takes care of cases where the surrounding text is in italics. See for example \textbf{$\aumlaut$}. –  T. Verron Feb 13 '13 at 15:18
That's right. You will have to define another command for each case. –  Count Zero Feb 13 '13 at 15:39