这是一个 MWE:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[german,hungarian]{babel}
\begin{document}
babel test
\end{document}
当我在此 MWE 上运行 pdflatex 时,程序停止并显示:
pdflatex babel-test.tex
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./babel-test.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-04-10>
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/fontenc.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/inputenc.sty)
(/usr/local/texlive/2022/texmf-dist/tex/generic/babel/babel.sty
(/usr/local/texlive/2022/texmf-dist/tex/generic/babel/txtbabel.def)
(/usr/local/texlive/2022/texmf-dist/tex/generic/babel-german/german.ldf
(/usr/local/texlive/2022/texmf-dist/tex/generic/babel-german/germanb.ldf))
(/usr/local/texlive/2022/texmf-dist/tex/generic/babel-hungarian/magyar.ldf))
(/usr/local/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def)
(./babel-test.aux)
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/article.cls) [1{/usr/local
/texlive/2022/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./babel-test.aux
! Missing number, treated as zero.
<to be read again>
\hskip
l.4 \catcode `"
\active
?
这是为什么?我该如何解决?我刚刚在 Linux 上安装了 TeXLive 2022。
谢谢。
答案1
magyar.ldf 修补(内部)latex 命令\@begindocumenthook
以将一些代码注入 aux 文件:
{\toks@\expandafter{\expandafter\@@magyar@protect@backtick\@begindocumenthook}%
\xdef\@begindocumenthook{\the\toks@}}% Dat: \@begindocumenthook has #1 #2 etc.
随着 latex 中新钩子系统的引入,这不再按预期工作。catcode 更改太晚了。
作者两年前已获悉此事,但 magyar.ldf 尚未被改编。
作为一种解决方法,您可以在 \begin{document} 之前重置有问题的 catcode:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[german,hungarian]{babel}
\AddToHook{begindocument}[test]{\catcode\string``=12 }
\DeclareHookRule{begindocument}{test}{before}{babel}
\begin{document}
babel test
\end{document}
我删除了 inputenc 行,因为它不再需要:几年来,utf8 一直是默认设置。