Sophanatprime / cus

CusTeX
8 stars 4 forks source link

`\setupnexttitle` 没有产生“作用一次”的效果,仍然影响了后面的所有命令 #18

Closed xkwxdyy closed 1 month ago

xkwxdyy commented 1 month ago

MWE

% !TeX program = xelatex
\documentclass{ctexbook}
\usepackage{cus}

\begin{document}
\section{测试}
test
\setupnexttitle { format+ = \large }
\section{测试}
test
\section{测试}
\section{测试}
test

\end{document}

编译后发现仍然影响了后面所有的标题。 image

问题

除了上面这个问题外,还有一个看了手册关于 \setupnexttitle 的描述

+ 的,把 {⟨title keys⟩} 附加到之前所保存的选项之后

% !TeX program = xelatex
\documentclass{ctexbook}
\usepackage{cus}

\begin{document}
\section{测试}
\setuponetitle{section}{format=\zihao{2}}
\section{测试}
\section{测试}
test
\setupnexttitle + { format+ = \large }
\section{测试}
test
\section{测试}
\section{测试}
test

\end{document}

测试了一下,看不出和没有 + 的区别。能否给一个例子说明加了 + 后效果不同,以及那个

? 的,仅会设置已知的选项,当选项未定义时会忽略它们,当为某些标题定义了额外的键时,它很有用。

能够给一个 当为某些标题定义了额外的键时,它很有用 的场景例子呢?

Sophanatprime commented 1 month ago

测试了一下,看不出和没有 + 的区别。能否给一个例子说明加了 + 后效果不同

\setupnexttitle{format+=\large}
\setupnexttitle{numberformat+\Huge}

只有后面这个生效

\setupnexttitle{format+=\large}
\setupnexttitle+{numberformat+\Huge}

两个都生效。

由于一个标题完成后会清空保存的这些键值,所以

\setupnexttitle{format+=\large}
\section{1}
\setupnexttitle+{numberformat+\Huge}
\chapter{2}

第一个 \setupnexttitle 只会作用于第一个标题。

能够给一个 当为某些标题定义了额外的键时,它很有用 的场景例子呢?

假设 \chapter 定义了一个键 chapter-special,而 \section 没有,那么

\setupnexttitle{format=\large, chapter-special=?}
\section{1}

会出错,而使用 \setupnexttitle?{format=\large, chapter-special=?} 不会。

? 这个功能是因为,cus 支持自定义标题的类别(比如 \chaptertop 类,\sectionnormal 类,和 titlesec 类似,用于控制标题整体的输出,比用键值控制的范围更广),且在自定义标题类时,除了默认定义的键值外,还可以自己增加新的键值。