# 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

In Text mode \"o begets a lower case O with two dots above. Any upper or lower case letter, or, interestingly enough, number, as well as some characters can be umlauted. This character sequence does not work in Math Mode.

In Math Mode (in between ) use \ddot{o}. Again, you can substitute any letter, number or some characters for the o in the foregoing character string.

FYI using the Windows's character map alt+0246 for example, does not work. Neither does copying and pasting out of MSWord. I've tried it to no avail.

-
Regarding your last point, that actually depends on the input encoding. The inputenc package allows you to set the input encoding to UTF-8 and input the characters directly. Standard encoding, however, does not recognise ö as a character and it is to be obtained in the manner you describe. That applies, of course, to text mode only, math mode is a whole different beast – Au101 Dec 11 '15 at 17:28
This is better-suited as a comment... – Werner Dec 11 '15 at 17:31