XeLaTeX:scrartcl + \setmainlanguage{russian} = “LaTeX 错误:\chapterformat 未定义。”

XeLaTeX:scrartcl + \setmainlanguage{russian} = “LaTeX 错误:\chapterformat 未定义。”

文档.tex:

\documentclass[a4paper]{scrartcl}

\usepackage{polyglossia}
\setmainfont{DejaVu Sans}
\newfontfamily{\cyrillicfontsf}{DejaVu Sans}
\newfontfamily{\cyrillicfonttt}{DejaVu Sans Mono}

\setmainlanguage{russian}

\begin{document}
    \section{Тест}
\end{document}

输出xelatex doc.tex

This is XeTeX, Version 3.14159265-2.6-0.99999 (TeX Live 2018/Arch Linux) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
(./doc.tex
LaTeX2e <2018-04-01> patch level 5
(/usr/share/texmf-dist/tex/latex/koma-script/scrartcl.cls
Document Class: scrartcl 2018/03/30 v3.25 KOMA-Script document class (article)
(/usr/share/texmf-dist/tex/latex/koma-script/scrkbase.sty
(/usr/share/texmf-dist/tex/latex/koma-script/scrbase.sty
(/usr/share/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texmf-dist/tex/latex/koma-script/scrlfile.sty)))
(/usr/share/texmf-dist/tex/latex/koma-script/tocbasic.sty)
(/usr/share/texmf-dist/tex/latex/koma-script/scrsize11pt.clo)
(/usr/share/texmf-dist/tex/latex/koma-script/typearea.sty))
(/usr/share/texmf-dist/tex/latex/polyglossia/polyglossia.sty
(/usr/share/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(/usr/share/texmf-dist/tex/latex/makecmds/makecmds.sty)
(/usr/share/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(/usr/share/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/share/texmf-dist/tex/generic/xkeyval/xkvutils.tex)))
(/usr/share/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/share/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(/usr/share/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/share/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/share/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def)))
(/usr/share/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/share/texmf-dist/tex/latex/base/fontenc.sty
(/usr/share/texmf-dist/tex/latex/base/tuenc.def))
(/usr/share/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/usr/share/texmf-dist/tex/generic/oberdiek/ifluatex.sty)
(/usr/share/texmf-dist/tex/generic/ifxetex/ifxetex.sty))
(/usr/share/texmf-dist/tex/latex/polyglossia/gloss-russian.ldf
(/usr/share/texmf-dist/tex/latex/polyglossia/babelsh.def))
No file doc.aux.

! LaTeX Error: \chapterformat undefined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.10 \begin{document}

当我删除该\setmainlanguage行时,错误消失,但西里尔字符也消失

我可以通过手动定义一个\chapterformat之前来修复它\begin{document},但感觉像一个 hack

答案1

russian的模块有polyglossia一部分代码是专门用于 Komascript 类的;不幸的是,它\renewcommand{\chapterformat}{...}在没有检查它是否被定义(不在scrartcl)的情况下就发出了问题。

为修复此问题,您可以为 提供一个虚拟定义。如果类更改为支持 的类,则\chapterformat使用将不执行任何操作。\providecommand\chapterformat

\documentclass[a4paper]{scrartcl}
\providecommand{\chapterformat}{}

\usepackage{polyglossia}
\setmainfont{DejaVu Sans}
\newfontfamily{\cyrillicfontsf}{DejaVu Sans}
\newfontfamily{\cyrillicfonttt}{DejaVu Sans Mono}

\setmainlanguage{russian}

\begin{document}

\section{Тест}

\end{document}

该问题已在polyglossia存储库中报告:

https://github.com/reutenauer/polyglossia/issues/210

我添加了建议的修复方法。

相关内容