latex3 / babel

The babel system for LaTeX, LuaLaTeX and XeLaTeX
LaTeX Project Public License v1.3c
125 stars 34 forks source link

Problem with \usepackage[german]{babel}: Umlaute #157

Closed BAMIP closed 2 years ago

BAMIP commented 2 years ago

Sir,

\documentclass[a4paper,12pt]{article} \usepackage[german]{babel} \newcommand{\damals}{5. M"arz 2018} \newcommand{\betr}{Zahlungs"ubersicht} \begin{document} {\damals} {\betr} \end{document}

will produce

  1. M"arz 2018 Zahlungs"ubersicht

The correct compilation should produce

  1. März 2018 Zahlungsübersicht

Is this a babel bug or an issue in my latex-file?

Thank you,

Michael

u-fischer commented 2 years ago

shorthands like " are only activated at the begin of the document. Either move your definitions behind \begin{document} or activate them:

\documentclass[a4paper,12pt]{article}
\usepackage[german]{babel}
\shorthandon{"} %<-------
\newcommand{\damals}{5. M"arz 2018}
\newcommand{\betr}{Zahlungs"ubersicht}
\begin{document}
{\damals}
{\betr}
\end{document}

But I would type the umlauts directly (assuming a current latex and a file encoded in utf8)

\newcommand{\damals}{5. März 2018}
\newcommand{\betr}{Zahlungsübersicht}
jbezos commented 2 years ago

Another alternative is:

\newcommand{\damals}{5. M\babelshorthand{"a}rz 2018}
\newcommand{\betr}{Zahlungs\babelshorthand{"u}bersicht}

Useful with shorthands like "- (see the example in section 1.10 of the babel manual), but definitely clumsy with letters. The best option, by far, is the one proposed by @u-fischer, namely, type directly ä and ü.