标题中的德语变音符号破损

标题中的德语变音符号破损

由于我将版本升级到了 Ubuntu 20.04,因此 latex 的版本如下:

pdflatex -version
pdfTeX 3.14159265-2.6-1.40.20 (TeX Live 2019/Debian)
kpathsea version 6.3.1
Copyright 2019 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.37; using libpng 1.6.37
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 4.01

如果使用listings和包,标题中使用德语变音符号将不再像以前那样起作用。hyperref

举个最小的例子:

\documentclass[12pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{listings}

\usepackage[pdftitle={Ä test},
           hidelinks]{hyperref}

\title{Ä test}

\begin{document}

This is a test

\end{document}

结果是

...
(/usr/share/texlive/texmf-dist/tex/latex/auxhook/auxhook.sty)
(/usr/share/texlive/texmf-dist/tex/latex/kvoptions/kvoptions.sty)
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/usr/share/texlive/texmf-dist/tex/generic/intcalc/intcalc.sty)
(/usr/share/texlive/texmf-dist/tex/generic/etexcmds/etexcmds.sty)
! Argument of \def has an extra }.
<inserted text> 
                \par 
l.4421 \ProcessKeyvalOptions{Hyp}
                                 
? 

当我用 AE 替换 Ä 时,它可以工作,但如果我像建议的那样用 {\A} 替换 Ä 例如如何在参考书目中书写“ä”及其他变音符号和重音字母?出現錯誤。

有没有办法安全地使用变音符号,listings以及hyperref在当前的 pdflatex 中?

答案1

问题出在时机上。如果你加载\usepackage[T1]{fontenc},那么Ä通过扩展就可以变成正确的字符。但是,其他特殊字符可能会导致同样的问题,所以这并不完全安全。

改用\hypersetup

另一方面,建议对德语使用 T1 编码。

\documentclass[12pt]{scrartcl}
%\usepackage[utf8]{inputenc} % no longer necessary
\usepackage[T1]{fontenc} % recommended for German
\usepackage[ngerman]{babel}
\usepackage{listings}

\usepackage{hyperref}
\hypersetup{
  pdftitle={Ä test},
  hidelinks,
}

\title{Ä test}

\begin{document}

This is a test

\end{document}

在此处输入图片描述

相关内容