Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
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
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 '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
show 2 more comments

3 Answers

up vote 6 down vote accepted

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.

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

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

share|improve this answer
    
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
add comment

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.

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.