我刚刚执行了完整的 TL 更新(--all
)(1 小时前)并发现我的一个以前可以编译成功的文档现在出现错误。
经过反复试验,发现问题出现在包含 时titlesec
。scrbook
但在 TeX 发行版更新之前,这曾经工作正常。
平均能量损失
\documentclass[11pt]{scrbook}%
%\documentclass[11pt]{book}%
\usepackage[raggedright]{titlesec}
\errorcontextlines=200
\begin{document}
\mainmatter
\chapter{Introduction, Summary of results and lookup table}
\section{Introduction}
stuff
\end{document}
现在lualatex index.tex
给出
>lualatex index.tex
This is LuaTeX, Version 1.10.0 (TeX Live 2019)
restricted system commands enabled.
(./index.tex
LaTeX2e <2018-12-01>
luaotfload | main : initialization completed in 0.134 seconds
(/usr/local/texlive/2019/texmf-dist/tex/latex/koma-script/scrbook.cls
Document Class: scrbook 2019/02/01 v3.26b KOMA-Script document class (book)
(/usr/local/texlive/2019/texmf-dist/tex/latex/koma-script/scrkbase.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/koma-script/scrbase.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/koma-script/scrlfile.sty)))
(/usr/local/texlive/2019/texmf-dist/tex/latex/koma-script/tocbasic.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/koma-script/scrsize11pt.clo)
(/usr/local/texlive/2019/texmf-dist/tex/latex/koma-script/typearea.sty))
Class scrbook Warning: Usage of package `titlesec' together
(scrbook) with a KOMA-Script class is not recommended.
(scrbook) I'd suggest to use the package only
(scrbook) if you really need it, because it breaks several
(scrbook) KOMA-Script features, i.e., option `headings' and
(scrbook) the extended optional argument of the section
(scrbook) commands.
(scrbook) Nevertheless, using requested
(scrbook) package `titlesec' on input line 5.
(/usr/local/texlive/2019/texmf-dist/tex/latex/titlesec/titlesec.sty
Package titlesec Warning: Non standard sectioning command \section
(titlesec) detected. Using default spacing and no format.
Package titlesec Warning: Non standard sectioning command \subsection
(titlesec) detected. Using default spacing and no format.
Package titlesec Warning: Non standard sectioning command \subsubsection
(titlesec) detected. Using default spacing and no format.
Package titlesec Warning: Non standard sectioning command \paragraph
(titlesec) detected. Using default spacing and no format.
Package titlesec Warning: Non standard sectioning command \subparagraph
(titlesec) detected. Using default spacing and no format.
) (./index.aux)
chapter 1.
! Missing number, treated as zero.
<to be read again>
}
\ttl@select ...@passexplicit \ttl@case \ttl@c {#2}
{#3}{#4}\fi \endgroup
\ttl@straight@ii ...t \ttl@select {#6}{#1}{#2}{#7}
\ttl@finmarks \@ifundefine...
l.13 \section{Introduction}
?
如果我使用该类book
,前面的 MWE 编译时不会出现任何错误。
什么变化导致此操作失败?不能再使用titlesec
with吗scrbook
?
Ubuntu 上的 TL 2019(在 Windows 10 Linux 子系统下)
答案1
titlesec
不支持 KOMA-Script 类。所以不要组合它们。要更改章节、节等标题的布局,您可以使用 KOMA-Script 选项和& \RedeclareSectionCommand
Co,并且可以重新定义\partlineswithprefixformat
、\chapterlineswithprefixformat
、\chapterlinesformat
和。\sectionlinesformat
\sectioncatchphraseformat
直到版本 3.26b KOMA-Script在发布该包时,提供了一个肮脏的内部 hack 来处理titlesec
这些类。但它检查了版本,titlesec
如果版本较新,则禁用了该解决方法。另请参阅https://komascript.de/release3.26b- »Bekannte Probleme« - »scrartcl, scrbook, scrreprt:«(德语)。
自 KOMA-Script 版本 3.27 起内部titlesec
解决方法已被删除,在 KOMA-Script 3.27 版或更高版本中将不再有此类内部解决方法。但 3.27 版为软件包提供了一种新技巧scrhack
,可以使用软件包选项启用standardsections
(默认情况下未设置)。然后,分段级别的命令与标准类兼容,但与分段命令有关的几个 KOMA-Script 功能被禁用(导致警告)。
例子:
\documentclass[
%11pt% default
]{scrbook}[2019/07/29]% needs prerelease of version 3.27 or newer
\usepackage[standardsections]{scrhack}
\usepackage[raggedright]{titlesec}
\begin{document}
\mainmatter
\chapter{Introduction, Summary of results and lookup table}
\KOMAScriptVersion
\section{Introduction}
stuff
\end{document}
使用 KOMA-Script 版本 3.26b 或 3.27 进行破解(不建议): 如果您确实想titlesec
与 结合使用scrbook
,则对文档中使用但未被 重新定义 的\RedeclareSectionCommands
所有低于 的部分级别使用:chapter
\titleformat
\documentclass[
%11pt% default
]{scrbook}
\usepackage[raggedright]{titlesec}
\RedeclareSectionCommands{section}
\begin{document}
\mainmatter
\chapter{Introduction, Summary of results and lookup table}
\KOMAScriptVersion
\section{Introduction}
stuff
\end{document}