Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: 章节等的样式会被修改,不应保存在常量 \c__..._tl #240

Closed
4 tasks done
muzimuzhi opened this issue Mar 7, 2024 · 4 comments
Closed
4 tasks done
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@muzimuzhi
Copy link
Contributor

先决条件

期望的现象

会被修改的 token list variable,视修改是局部还是全局,应命名为 \l_..._tl\g_..._tl

发生了什么

目前项目里大量使用形如 \c_..._tl 的 constant token list variable,它们有的不是 constant/常量,目前的命名不合适。

constant 意味着创建同时赋值,且后续不应修改。默认没有硬性约束,使用 \debug_on:n { check-declarations } 能报告一些错误的用法。

我没有完整检查,但 \c_@@_fmt_...tl 一类看起来都应该使用 \l_@@_fmt_...tl

NJUThesis/source/njuthesis.dtx

Lines 2887 to 2893 in 4bd5fd2

% \begin{macro}{\@@_define_fmt:nn}
% 用来定义默认样式的辅助函数。
% \begin{macrocode}
\cs_new_protected:Npn \@@_define_fmt:nn #1#2
{ \tl_const:cn { c_@@_fmt_ #1 _tl } {#2} }
% \end{macrocode}
% \end{macro}

最小工作示例

% !TeX program = xelatex
\documentclass{njuthesis}

\ExplSyntaxOn
\debug_on:n { check-declarations }
\ExplSyntaxOff
\njusetformat{chapterintoc}{\heiti}

\begin{document}

\ExplSyntaxOn
\cs_meaning:N \c__nju_fmt_chapterintoc_tl
\ExplSyntaxOff
%\maketitle
\tableofcontents
\mainmatter
\chapter{欢迎}
使用 \LaTeX{}!
\printbibliography
\end{document}

njuthesis 模板版本

v1.3.2

模板获取途径

使用包管理器从 CTAN 安装

操作系统

macOS

TeX 发行版

TeX Live 2023

编译程序

XeLaTeX

额外信息

  • texdoc interface3 (2024-02-20), sec. 1.1 Naming functions and variables, p. 3

    c Constant: global parameters whose value should not be changed.

  • texdoc interface3 (2024-02-20), sec. 4.8 Debugging support, doc for \debug_on:n
@muzimuzhi muzimuzhi added the bug Something isn't working label Mar 7, 2024
@atxy-blip atxy-blip added the help wanted Extra attention is needed label Mar 7, 2024
@atxy-blip
Copy link
Member

atxy-blip commented Mar 12, 2024

回想了一下最开始写这块组件的思路,是从 fduthesis 抄来的,见 fduthesis.dtx#L2923-L2935。 曾老师那个模板中各种嵌入的文字可以定死不动,但是呢,南大教务给的要求很模糊,经常有同学要灵活调整,我就给了个赋值接口 (._.)

实际上我也很迷糊,这些 c 量在绝大多数情况下是不用更改,是否要为了偶发情况全都改成 g 型……

@muzimuzhi
Copy link
Contributor Author

我想的是,如果没有禁止多次设置某个选项,那么就不能把选项值存在常量里。哪怕大部分时候这些选项只设置一次。

如果有局部修改样式的需求,也许用 l 型更灵活,可以支持 {<local setting> <content>} 这样的用法。

我得去看一下 fduthesis,看看它是不是也实际允许多次设置那些选项。

@atxy-blip
Copy link
Member

atxy-blip commented Mar 18, 2024

我得去看一下 fduthesis,看看它是不是也实际允许多次设置那些选项

是没有的。大概复旦的规定有比较好的一致性,没有这种需求。

我把所有可能被修改的 c 型都改成了 l 型。仔细一想在这个点上纠结确实有点,蠢 orz


现在 check-declarations 只会报告 xeCJK 自身的误用,以及一处(我没头绪的)全局修改了 \@begindvi 的误用。

@muzimuzhi muzimuzhi changed the title [Bug]: 章节等的样式不应保存在 constant token list variable 里 [Bug]: 章节等的样式会被修改,不应保存在常量 \c__..._tl Mar 18, 2024
atxy-blip added a commit that referenced this issue Mar 19, 2024
- draft 选项不接受输入值
atxy-blip added a commit that referenced this issue Mar 19, 2024
- draft 选项不接受输入值
@atxy-blip
Copy link
Member

哇啊,rebase 把提交记录搞得好乱。就这样吧全都改好了。

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants