[Tex/LaTex] Umlauts in math mode

accentsmath-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 .

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}

Best Answer

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

Sample output

\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
\begin{equation}
    \textnormal{Empf"anger}
\end{equation}
test

\end{document}

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