sectsty 如何与 LaTeX 中 scrbook-documentclass 中的 \part 一起使用?
在这个问题中,我问,如何在部分下生成规则。使用 sectsty 提供的答案满足了我的要求,但引发了一个问题:如果我使用包 sectsty , \part-command 会产生错误:
! Undefined control sequence.
\NR@part ...elax \refstepcounter {part}\@maybeasf
\addcontentsline {toc}{par...
l.8 \part{partname}
如果我使用 book-documentclass 而不是 scrbook,它可以正常工作。但我使用了 Komascript 的很多功能,所以我不想切换。知道有人有解决方案吗,我如何才能同时使用两者?
编辑:以下简单示例重现了该问题:
\documentclass{scrbook}
\usepackage{sectsty}
\begin{document}
\part{test} % crash and burn here
\end{document}
In this question I asked, how to produce rules under sections. The answer provided using sectsty does what I wish, but triggers a problem: If I use the package sectsty the \part-command produces an error:
! Undefined control sequence.
\NR@part ...elax \refstepcounter {part}\@maybeasf
\addcontentsline {toc}{par...
l.8 \part{partname}
If I use book-documentclass instead of scrbook, it works all right. But I use much features of Komascript, so I don't want to switch. Knows anyone a solution, how I can use both together?
EDIT: Following simple example reproduces the problem:
\documentclass{scrbook}
\usepackage{sectsty}
\begin{document}
\part{test} % crash and burn here
\end{document}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是 sectsty 是为与旧版本的 scrbook 一起使用而编写的。如果您查看 sectsty.sty 文件的第 553 行,您会发现它使用了 1998 年 scrbook.cls v2.5e 中的一些代码。这就是问题发生的地方。如果你将最新版本的 scrbook.cls (v3.04a, 2009/07/24) 的相关部分拼接到 sectsty.sty 中,一切似乎都可以正常工作。我已经完成此操作并将文件放在此处。请注意,除了确保它在您的示例代码上运行正常之外,我还没有对此进行测试。
The problem is that sectsty was written to work with an older version of scrbook. If you look at the sectsty.sty file at line 553, you'll find that it uses some code from scrbook.cls v2.5e from 1998. That's where the problem is occurring. If you splice in the relevant section of the latest version of scrbook.cls (v3.04a, 2009/07/24) into sectsty.sty, it all seems to work ok. I've done this and put the file here. Note that I haven't tested this other than to make sure it runs ok on your example code.
那么...你使用什么类?标准书籍类还是 komascript 中的 srcbook?
如果您使用的是标准书籍类,sectsty 有 \part 命令的特定命令:
\partnumberfont{hcommandsi} 更改
part' 标题编号的样式
仅有的;这不会影响部分标题的标题。
\parttitlefont{hcommandsi} 更改部分标题的样式
仅有的;这不会影响零件标题的编号。
\partfont{hcommandsi} 仅通过执行来更改“部分”标题的样式
{hcommandsi} 在打印每个标题之前;这对双方都有影响
零件的标题和零件号。
如果您使用 KOMA-script 类,sectsty 文档指出:
如果您只想更改所有章节标题使用的字体,则
不应将 sectsty 与任何 KOMA 脚本类一起使用。相反,您应该重新定义 KOMA 脚本提供的 \sectfont 命令
如果您希望以不同的样式打印不同的部分标题
彼此的类型,或者如果您想在部分标题下划线或播放
您无法使用 KOMA-script \sectfont 命令执行的其他游戏,
那么 sectsty 可能会与 KOMA 脚本类一起使用。
您应该注意 sectsty 命令应用的修改
执行 \sectfont 命令后立即发生。
这个包的文档是用标准 LATEX 编写的
考虑到类,因此可能不完全与 KOMA 脚本类相关。
尽管如此,尽管出现问题时行为有所不同,
sectsty 应按预期与 KOMA 脚本类一起工作。
来自: Sectsty 文档第四章
编辑:如果您想要的只是在节和章节下添加一行,但仍想使用 \part 命令,为什么不放弃 sectsty,并使用 \hrule 在 koma-script 中重新定义分段命令呢?
So... what class are you using? The standard book class or the srcbook in komascript?
If you're using the standard book class, sectsty has specific commands for the \part command:
\partnumberfont{hcommandsi} Changes the style of
part' heading numbers
part' heading titlesonly; this does not aect the title of the part heading.
\parttitlefont{hcommandsi} Changes the style of
only; this does not aect the number of the part heading.
\partfont{hcommandsi} Changes the style of `part' headings only by executing
{hcommandsi} before printing each heading; this aects both
the title of the part and the part number.
If you're using the KOMA-script class, the sectsty documentation states:
If you just want to change the fount used for all sectional headings, you
shouldn't use sectsty with any of the KOMA-script classes. Instead, you should redene the \sectfont command provided by the KOMA-script
If you'd like dierent sectional headings to be printed with dierent styles
of type to each other, or if you'd like to underline sectional headings or play
other games that you can't do with the KOMA-script \sectfont command,
then sectsty might be of use with the KOMA-script classes.
You should note that the modications applied by sectsty commands
happen immediately after the \sectfont command is executed.
The documentation for this package is written with the standard LATEX
classes in mind, so might not tie up exactly to the KOMA-script classes.
Despite that, and despite dierences in behaviour when things go wrong,
sectsty should work as expected with the KOMA-script classes.
from: Sectsty Documentation Chapter Four
EDIT: If all you want is a line under your section and chapters, but still want to use the \part command, why not just ditch sectsty, and re-define the sectioning commands in koma-script using \hrule?