7

Although I known nothing about German, I have to complie some German TeX documents. The German quotation marks "' or \grqq and "' or \grqq in my document are replaced by cmr font and the PDF file is not copyable near the quotation marks. A warning message says

font shape `OT1/TeXGyrePagella(0)/m/n' undefined, using `OT1/cmr/m/n' instead for symbol `glqq' on line 9.

The following is my minimal example:

% !TEX program = xelatex
% !Mode:: "TeX:UTF-8"
\documentclass[12pt]{article}
\usepackage[ngerman]{babel}
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont{TeXGyrePagella}
\begin{document}
These are German \glqq quotation marks\grqq.
\end{document} 
10

Never use babel with XeLaTeX. For internationalization support use polyglossia instead. Besides, in this case it's not even needed. You can enter the quotation marks either using ASCII symbols or direct UTF-8:

\documentclass{article}

\usepackage{fontspec}

\setmainfont[Ligatures = TeX]{TeX Gyre Pagella}

\begin{document}

<< >> ,, ``

« » „ “

\end{document}

polyglossia also has some babel shorthand support to ease the transition from babel.

  • Simply great answer! – Ma Ming Apr 29 '11 at 23:37
  • 2
    @AndreyVihrov: Hi, in the meantime babel supports XeTeX too, maybe you like to add this to you answer :-) – Tobi Mar 10 '16 at 12:45
8

Update (March 2016)
babel now supports XeTeX so the following will work:

% !TEX program = xelatex
% !Mode:: "TeX:UTF-8"
\documentclass[12pt,ngerman]{article}

\usepackage{babel}

\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text}

\begin{document}
These are German \glqq quotation marks\grqq.
These are German "`quotation marks"'.
\end{document}

Original Answer
Think you’d better use polyglossia instead of babel:

% !TEX program = xelatex
% !Mode:: "TeX:UTF-8"
\documentclass[12pt]{article}
\usepackage{polyglossia}
    \setmainlanguage[spelling=new,babelshorthands=true]{german}
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont{Times New Roman}
\newcommand\glqq{"`}
\newcommand\grqq{"'}
\begin{document}
Thess are German \glqq quotation marks\grqq.
Thess are German "`quotation marks"'.
\end{document}

(I changed the font …)

  • Yes, I known such a package and advise. I've tryed it but not succeed. My code was essential the same with yours, the error msg says !missing number, treated as zero <to be read again>\l@german... – Ma Ming Apr 29 '11 at 23:33
  • @Ma “essential the same” means not identical, right? Could you provide the minimal example that gives this error? Maybe it’ll help to update your TeX-system first. – Tobi Apr 30 '11 at 8:38
  • @Ma Ming: an error is normal during the first run of XeLaTeX after you change from babel to polyglossia. It's caused by an annotation in the .aux file and is to be ignored; it won't happen any more. – egreg Apr 30 '11 at 10:35
  • @Tobi Finally I figure out I need etoolbox to support polyglossia. – Ma Ming May 20 '11 at 19:51
  • 1
    @Tobi Yes, polyglossia relies on etoolbox. – Ma Ming May 20 '11 at 22:28
3

When using babel you should check if the language definition files you want to use are already adapted to the unicode engines -- this isn't the case for a number of non-western scripts -- but with (n)german it will work fine with xelatex. You are not getting the quote because xunicode doesn't provide the necessary definitions. It is easy to add them. E.g.

\documentclass[12pt]{article}
\usepackage[ngerman]{babel}
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text}
\setmainfont{TeX Gyre Pagella}

\DeclareUTFcharacter[\UTFencname]{x201C}{\grqq}
\DeclareUTFcharacter[\UTFencname]{x201E}{\glqq}

\begin{document}
These are German \glqq quotation marks\grqq.
\end{document}

Also take a look at the package csquotes

(Edited on march 2016 to adapt to the new commands in fontspec and the development in babel.)

  • Hi, in the meantime babel supports XeTeX too, maybe you like to add this to you answer :-) – Tobi Mar 10 '16 at 12:45
  • @Tobi: I never wrote that babel doesn't support xetex. Actually the answer says explicitly that with ngerman ist works fine. The question is always only which of the language files have already support for the unicode engines. But I will update a bit the answer to adapt to the changes. – Ulrike Fischer Mar 10 '16 at 12:55
  • Ups … sorry :-) Actually I only read the first line of you answer before posting my comment O:-) – Tobi Mar 10 '16 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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