17

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}
8
  • 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, 2013 at 14:48
  • 1
    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, 2013 at 14:49
  • 1
    Side note: "a expands to \ddot a in math mode. Feb 13, 2013 at 14:50
  • 1
    I don't exactly why you don't want to use \text but probably you are looking for \text{\normalfont Empfänger}. Feb 13, 2013 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, 2013 at 14:54

4 Answers 4

15

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.

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

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.

3
  • 1
    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, 2015 at 17:28
  • 3
    This is better-suited as a comment...
    – Werner
    Dec 11, 2015 at 17:31
  • @Werner look at the user, they can't comment.
    – Rainb
    Feb 15, 2021 at 9:32
1

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

2
  • 1
    If the text around the equation is italics (e.g. a theorem), \text will print the text as italics too.
    – T. Verron
    Feb 13, 2013 at 14:49
  • Yes. Also allows use of utf8 encoded text, i.e. you can type the umlauts in directly.
    – Karl
    Sep 22, 2016 at 11:28
0

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.

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

You must log in to answer this question.

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