我想用 XeLaTeX 重新运行几个月前的文档,但在使用 Polyglossia 加载匈牙利语时收到意外错误消息:
\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage{hungarian}
\begin{document}
Példa.
\end{document}
除其他外,我收到以下错误:
You can't use `macro parameter #' in vertical mode.
我的 MikTeX 发行版已于今天更新。
另请参阅 GitHub 上的:https://github.com/reutenauer/polyglossia/issues/388
答案1
更新
该问题已在polyglossia
2020-01-29 发布的 1.47 版中修复。
早期版本的答案
问题出在代码中,代码\renewcommand
带有参数。最近的更改polyglossia
可能造成了这个问题。
解决方法:单独定义命令并执行\let
。
\documentclass[a4paper,12pt,twoside]{article}
\usepackage[margin=2.5cm]{geometry}
\usepackage{polyglossia}
\setmainlanguage{hungarian}
\makeatletter
\def\hungarian@capsformat{%
%
% Change captions
\if@hungarian@swapcaptions
% change 'ábra x.x' to 'x.x. ábra'
\def\fnum@figure{\thefigure.~\figurename}
%
% change 'táblázat x.x' to 'x.x. táblázat'
\def\fnum@table{\thetable.~\tablename}
\fi
%
% change chapter and part headings
\if@hungarian@swapheadings
% With titlesec
\ifdefined\titleformat%
\ifdefined\@part%
\let\xpg@save@part@format\@part%
\patchcmd{\@part}%
{\partname\nobreakspace\thepart}%
{\thepart.\nobreakspace\partname}%
{}%
{\xpg@warning{Failed to patch part for Hungarian}}%
\fi%
\ifdefined\chapter%
\titleformat\chapter[display]%
{\@ifundefined{ttl@fil}{\raggedright}{\ttl@fil}\ttl@fonts\ttl@sizes6}
{\thechapter.\space\@chapapp}{.8\baselineskip}{\ttl@sizes\z@\ttl@passexplicit}
\fi%
\else% (not \ifdefined\titleformat)
% With KOMA
\ifdefined\sectionformat%
\ifdefined\partformat%
\let\xpg@save@part@format\partformat%
\renewcommand{\partformat}{\thepart.~\partname}%
\fi%
\ifdefined\chapterformat%
\let\xpg@save@chap@format\chapterformat%
\renewcommand{\chapterformat}{\mbox{\thechapter\autodot%
\IfUsePrefixLine{\nobreakspace\chapapp}{\enskip}}}%
\fi%
\else% (not \ifdefined\sectionformat)
% With memoir
\ifdefined\@memptsize%
\ifdefined\@makechapterhead%
\let\xpg@save@chap@format\@makechapterhead%
\patchcmd{\@makechapterhead}{\printchaptername \chapternamenum \printchapternum}%
{\printchapternum.\chapternamenum\printchaptername}%
{}%
{\xpg@warning{Failed to patch chapter for Hungarian}}%
\fi%
\ifdefined\@part%
\let\xpg@save@part@format\@part%
\patchcmd{\@part}{\printpartname \partnamenum \printpartnum}%
{\printpartnum.\partnamenum\printpartname}%
{}%
{\xpg@warning{Failed to patch part for Hungarian}}%
\fi%
\else% (not \ifdefined\@memptsize)
% With standard classes
\ifdefined\@makechapterhead%
\let\xpg@save@chap@format\@makechapterhead%
\patchcmd{\@makechapterhead}%
{\@chapapp\space \thechapter}%
{\thechapter.\space \@chapapp}%
{}%
{\xpg@warning{Failed to patch chapter for Hungarian}}%
\fi%
\ifdefined\@part%
\let\xpg@save@part@format\@part%
\patchcmd{\@part}%
{\partname\nobreakspace\thepart}%
{\thepart.\nobreakspace\partname}%
{}%
{\xpg@warning{Failed to patch part for Hungarian}}%
\fi% (end \ifdefined\@part)
\fi% (end \ifdefined\@memptsize)
\fi% (end \ifdefined\sectionformat)
\fi% (end \ifdefined\titleformat)
\fi% (end \if@hungarian@swapheadings)
%
% Change running headers
\if@hungarian@swapheaders
\ifdefined\chapterformat%
% With KOMA
\let\xpg@save@chaptermark@format\chaptermarkformat%
\renewcommand*\chaptermarkformat{%
\thechapter\autodot\ \IfChapterUsesPrefixLine{\chapapp\enskip}{}}
\else% (not \ifdefined\chapterformat)
\ifdefined\@memptsize%
% With memoir
\let\xpg@save@chaptermark@format\chaptermark%
\let\chaptermark\hungarian@memoir@chaptermark % <----- CHANGED HERE
\else% (not \ifdefined\@memptsize)
% With standard classes
\ifdefined\chaptermark%
\let\xpg@save@chaptermark@format\chaptermark%
\patchcmd{\chaptermark}%
{\@chapapp\ \thechapter.}%
{\thechapter.\ \@chapapp}%
{}%
{\xpg@warning{Failed to patch chaptermark for Hungarian}}%
\fi% (end \ifdefined\chaptermark)
\fi% (end \ifdefined\@memptsize)
\fi% (end \ifdefined\chapterformat)
\fi% (end \if@hungarian@swapheaders)
}
\newcommand*{\hungarian@memoir@chaptermark}[1]{%
\markboth{
\memUChead{%
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\thechapter.\ \@chapapp\ %
\fi
\fi
#1%
}%
}{}%
}
\makeatother
\begin{document}
Példa.
\end{document}
查找CHANGED HERE
并与中的代码进行比较gloss-hungarian.ldf
。