Skip to content

Commit 7c37def

Browse files
YDX-2147483647fky2015
authored andcommitted
fix: listings 代码编号中的分隔标签
Fixes #589 Fixes #338 (again) Relates to #445
1 parent 25d9f7a commit 7c37def

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

bithesis.dtx

+15-13
Original file line numberDiff line numberDiff line change
@@ -703,19 +703,7 @@
703703
tabularFontSize .tl_set:N = \l_@@_misc_tabular_font_size_tl,
704704
tabularFontSize .initial:n = {5},
705705
arialFont .tl_set:N = \l_@@_misc_arial_font_path_tl,
706-
autoref / algo .code:n = {
707-
\AtBeginDocument{
708-
% 定义算法标题
709-
% 针对 algorithm 宏包
710-
\tl_set:Nn \ALG@name {#1}
711-
% 针对 algorithm2e 宏包
712-
\tl_set:Nn \algorithmcfname {#1}
713-
714-
% 定义算法的 autoref
715-
% algorithm2e 宏包会覆写它,所以我们必须AtBeginDocument时再修改
716-
\tl_set:Nn \algorithmautorefname {#1}
717-
}
718-
},
706+
autoref / algo .tl_set:N = \l_@@_misc_autoref_algo_tl,
719707
autoref / algo .initial:n = {\g_@@_const_autoref_algo_tl},
720708
autoref / them .tl_set:N = \themautorefname,
721709
autoref / them .initial:n = {\g_@@_const_autoref_them_tl},
@@ -985,6 +973,10 @@
985973
% \subsubsection{定义模板类样式}
986974
%
987975
% 加载所需的宏包。
976+
%
977+
% 在加载宏包之前,尽量不使用 AtBeginDocument 等 hook。
978+
% 因为 listings 等宏包也会用这些 hook。若在加载它们之前使用 hook,会导致我们所有 hook 在这些宏包“之前”运行。
979+
%
988980
% \begin{macrocode}
989981
\RequirePackage{geometry}
990982
\RequirePackage[table,xcdraw]{xcolor}
@@ -1675,6 +1667,16 @@
16751667
\cs_gset:Npn \thelstlisting {\thechapter\g_@@_label_divide_char_tl\arabic{lstlisting}}
16761668
\cs_gset:Npn \lstlistingname {\c_@@_label_code_tl}
16771669

1670+
% 定义算法标题
1671+
% 针对 algorithm 宏包
1672+
\tl_set:Nn \ALG@name {\l_@@_misc_autoref_algo_tl}
1673+
% 针对 algorithm2e 宏包
1674+
\tl_set:Nn \algorithmcfname {\l_@@_misc_autoref_algo_tl}
1675+
1676+
% 定义算法的 autoref
1677+
% algorithm2e 宏包会覆写它,所以我们必须AtBeginDocument时再修改
1678+
\tl_set:Nn \algorithmautorefname {\l_@@_misc_autoref_algo_tl}
1679+
16781680
% 算法变成「章节号-序号」
16791681
% 为了减少修改,我们只适配按章编号的情况。
16801682
% 针对 algorithm 宏包

0 commit comments

Comments
 (0)