ctex: `beforeskip` 和 `afterskip` 在引入 `titlesec` 宏包后失效
如题,在引入titlesec宏包之后,使用\ctexset设置的beforeskip以及afterskip失效。
如下MWE:
- 若注释
titlesec,则beforeskip以及afterskip的设置有效:
\documentclass{ctexbook}
% \RequirePackage{titlesec}
\usepackage{xcolor}
\makeatletter
\ctexset{subsection={
beforeskip = {50pt},%% modified here
afterskip = {50pt},%% modified here
}
}
\makeatother
\usepackage{zhlipsum}
\begin{document}
\mainmatter
\chapter{使用示例}
\section{各类环境的用法}
\zhlipsum[2]
\subsection{测试}
\zhlipsum[2]
\subsection{测试}
\zhlipsum[2]
\end{document}
- 若不注释
titlesec宏包,则上述的设置失效
我在ctex文档中仅在14.8.2.7节找到了有关对titlesec宏包的兼容的说明中提到:
它的第四个(⟨beforeskip⟩)和第五个(⟨afterskip⟩)参数的符号不再有特殊意义,改由相应的选项 afterindent 和 runin 来控制。
我不太确定这是否可以作为上述现象的解释,另外这里的文档是否藏得有些太深了,在文档的7.3节中对beforeskip以及afterskip的说明时是否可以提及这里与titlesec存在冲突以让这一问题更容易被注意到。
我个人知道当使用ctex-kit时,对于目录标题的控制基本上可以使用\ctexset提供的强大功能实现,因此是很少有必要再调用titlesec的。
所以有必要提及上面问题的出现场景:
在qbook.cls中,使用了ctexbook的同时调用了\RequirePackage{titlesec}:
https://github.com/muzimuzhi/Qbook/blob/b84e37a5a86c4249f2bc6dba1df4a2c70d6e41f7/qbook.cls#L24
这会导致用户在如下\ctexset中增加对aboveskip以及belowskip的控制时“隐式”地失效:
https://github.com/muzimuzhi/Qbook/blob/b84e37a5a86c4249f2bc6dba1df4a2c70d6e41f7/qbook.cls#L155-L176
当然qbook已经archived......
诶这个创建指向代码段的永久链接要怎么显示代码来着...这里似乎使用姿势不太对....
诶这个创建指向代码段的永久链接要怎么显示代码来着...这里似乎使用姿势不太对....
This type of permanent link will render as a code snippet only in the repository it originated in. In other repositories, the permalink code snippet will render as a URL. This does not work in Markdown files, only in comments.
https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet
在
qbook.cls中,使用了ctexbook的同时调用了\RequirePackage{titlesec}:
ctex 里有兼容 titlesec 的逻辑,见 texdoc ctex, sec. 14.8.2.7 "兼容 titlesec 宏包"。兼容可能当时有效、随着 latex kernel 和 titlesec 更新,失效了。于是 qbook.cls 里的用法,可能曾经支持、现在不支持了。
总的来说,不建议不加修改地使用 https://github.com/muzimuzhi/Qbook 里的 qbook.cls 了,这个仓库是别人转给我的,我自己没有使用需求,所以也没有维护,早早 archive 了。
如果有人需要继续使用它,可以自行尝试修改。有兴趣维护的话,我可以把仓库转给 ta。