Skip to content

Commit

Permalink
feat: support pageslts to get lastpage
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexaraWu committed Dec 31, 2024
1 parent 5d22ff0 commit 22751f6
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions sjtutex/source/sjtutex.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -1185,12 +1185,13 @@
% 页脚字体。默认为 |\zihao{-5}|,小五号字。
% \end{function}
%
% \begin{function}[added=2022-12-03]{style/page-number}
% \begin{function}[added=2022-12-03,updated=2024-12-30]{style/page-number}
% \begin{syntax}
% \OPT{page-number} = \marg{页码设置}
% \OPT{page-number} = \marg{格式定义}
% \end{syntax}
% 设置页码的显示样式,其中 |#1| 代表当前页码。
% 默认为 |{#1}|,即仅显示页码本身。
% 设置页码的显示格式,\meta{格式定义} 有两个参数:参数 |#1| 是当前页码,参数 |#2| 是当前编码的总页码数。
% 获取总页码数需要使用 \pkg{pageslts} 宏包。
% 默认为 |{#1}|,即仅显示当前页码。
% \end{function}
%
% \begin{function}[added=2023-11-30]{style/keywords-format}
Expand Down Expand Up @@ -3498,13 +3499,14 @@
% \end{macro}
%
% \begin{macro}{style/page-number}
% \begin{macro}[int]{\@@_page:n}
% \begin{macro}[int]{\@@_page:nn}
% 页脚页码格式。
% \begin{macrocode}
\cs_new:Nn \@@_thepage: { \thepage }
\tl_set:Nn \@@_the_page_tl { \thepage }
\tl_new:N \@@_the_last_page_tl
\keys_define:nn { sjtu / style }
{
page-number .cs_set:Np = \@@_page:n #1 ,
page-number .cs_set:Np = \@@_page:nn #1#2 ,
page-number .initial:n = { {#1} }
}
% \end{macrocode}
Expand Down Expand Up @@ -3543,7 +3545,7 @@
\fancyhead [ L ] { \l_@@_header_tl }
\fancyhead [ R ] { \@@_nouppercase:V \l_@@_rightmark_tl }
}
\fancyfoot [ C ] { \@@_page:n { \@@_thepage: } }
\fancyfoot [ C ] { \@@_page:nn { \@@_the_page_tl } { \@@_the_last_page_tl } }
% \end{macrocode}
%
% \begin{macro}{\headrule}
Expand Down Expand Up @@ -5248,6 +5250,7 @@
% \begin{macro}{digest}
% 大摘要。
% \begin{macrocode}
\NewHook { sjtutex / digest }
\NewDocumentEnvironment { digest } { O{ } +b }
{
\AtEndDocument
Expand All @@ -5257,7 +5260,8 @@
\legacy_if:nTF { @openright }
{ \cleardoublepage } { \clearpage }
\pagenumbering { roman }
\cs_gset:Nn \@@_thepage: { \arabic { page } }
\tl_gset:Nn \@@_the_page_tl { \arabic { page } }
\UseHook { sjtutex / digest }
\cs_gset_eq:NN \addcontentsline \use_none:nnn
\clist_map_inline:Nn \l_@@_counter_without_chapter_clist
{
Expand Down Expand Up @@ -5415,6 +5419,26 @@
}
% \end{macrocode}
%
% \changes{unreleased}{2024/12/30}{使用 \pkg{pageslts} 宏包获取总页码。}
% \subsubsection{\pkg{pageslts} 宏包}
%
% \begin{macrocode}
\ctex_at_end_package:nn { pageslts }
{
%<thesis> \pagenumbering { Alph }
%<!thesis> \pagenumbering { arabic }
\tl_set:Nn \@@_the_last_page_tl
{ \lastpageref { pagesLTS.\pagesLTS@pnc } }
%<*thesis>
\AddToHook { sjtutex / digest }
{
\tl_gset:Nn \@@_the_last_page_tl
{ \lastpageref { pagesLTS.roman.local } }
}
%</thesis>
}
% \end{macrocode}
%
% \subsubsection{\pkg{threeparttable} 宏包}
%
% \begin{macrocode}
Expand Down

0 comments on commit 22751f6

Please sign in to comment.