Skip to content

Commit 616e7b5

Browse files
committed
ctex: 更好地兼容 nameref 宏包。
1 parent ee88dc4 commit 616e7b5

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

ctex/ctex.dtx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ Copyright and Licence
581581
% \changes{v2.4.15}{2019/03/23}{同步 \LaTeXiii{} 2019/03/05。}
582582
%
583583
%
584-
% \CheckSum{5916}
584+
% \CheckSum{5934}
585585
%
586586
% \CharacterTable
587587
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -7375,6 +7375,7 @@ Copyright and Licence
73757375
\CTEX@makeanchor{part*}%
73767376
% \addcontentsline{toc}{part}{#1}%
73777377
\fi
7378+
\CTEX@gettitle{#1}%
73787379
\CTEX@addtocline{part}{#1}%
73797380
{\interlinepenalty \@M
73807381
% \normalfont \parindent \z@ \raggedright
@@ -7414,6 +7415,7 @@ Copyright and Licence
74147415
\CTEX@makeanchor{part*}%
74157416
% \addcontentsline{toc}{part}{#1}%
74167417
\fi
7418+
\CTEX@gettitle{#1}%
74177419
\CTEX@addtocline{part}{#1}%
74187420
% \markboth{}{}%
74197421
\partmark{#1}%
@@ -7440,6 +7442,7 @@ Copyright and Licence
74407442
\def\@spart#1{%
74417443
\CTEX@ifnamefalse
74427444
\CTEX@makeanchor@spart{part*}%
7445+
\CTEX@gettitle{#1}%
74437446
{\interlinepenalty \@M
74447447
% \normalfont \parindent \z@ \raggedright
74457448
\CTEX@disableautoindent
@@ -7459,6 +7462,7 @@ Copyright and Licence
74597462
\def\@spart#1{%
74607463
\CTEX@ifnamefalse
74617464
\CTEX@makeanchor@spart{part*}%
7465+
\CTEX@gettitle{#1}%
74627466
{\interlinepenalty \@M
74637467
% \normalfont \centering
74647468
\CTEX@disableautoindent
@@ -7550,6 +7554,7 @@ Copyright and Licence
75507554
\CTEX@makeanchor@chapter{\Hy@chapapp*}%
75517555
% \addcontentsline{toc}{chapter}{#1}%
75527556
\fi
7557+
\CTEX@gettitle{#1}%
75537558
\CTEX@addtocline{chapter}{#1}%
75547559
\chaptermark{#1}%
75557560
% \addtocontents{lof}{\protect\addvspace{10\p@}}%
@@ -7569,6 +7574,7 @@ Copyright and Licence
75697574
\def\@schapter#1{%
75707575
\CTEX@ifnamefalse
75717576
\CTEX@makeanchor@schapter{\Hy@chapapp*}%
7577+
\CTEX@gettitle{#1}%
75727578
\if@twocolumn
75737579
\@topnewpage[\@makeschapterhead{#1}]%
75747580
\else
@@ -7696,6 +7702,7 @@ Copyright and Licence
76967702
\let\@svsec\@empty
76977703
\fi
76987704
\fi
7705+
\CTEX@gettitle{#7}%
76997706
% \@tempskipa #5\relax
77007707
% \ifdim \@tempskipa>\z@
77017708
\unless \ifodd \CTEX@runin
@@ -7737,6 +7744,7 @@ Copyright and Licence
77377744
% \begin{macrocode}
77387745
\def\@ssect#1#2#3#4#5{%
77397746
\CTEX@ifnamefalse
7747+
\CTEX@gettitle{#5}%
77407748
% \@tempskipa #3\relax
77417749
% \ifdim \@tempskipa>\z@
77427750
\unless \ifodd \CTEX@runin
@@ -8006,6 +8014,27 @@ Copyright and Licence
80068014
}
80078015
% \end{macrocode}
80088016
%
8017+
% \paragraph{兼容 \pkg{nameref} 宏包}
8018+
%
8019+
% \changes{v2.4.16}{2019/05/29}{更好地兼容 \pkg{nameref} 宏包。}
8020+
%
8021+
% \begin{macro}[int]{\CTEX@gettitle}
8022+
% 在 \pkg{nameref} 载入后才有意义,与上述 \pkg{hyperref} 的处理类似。
8023+
% \begin{macrocode}
8024+
\cs_new_protected:Npn \CTEX@gettitle #1
8025+
{ }
8026+
\ctex_at_end_package:nn { nameref }
8027+
{
8028+
\cs_gset_protected_nopar:Npn \CTEX@gettitle { \NR@gettitle }
8029+
\seq_map_inline:Nn \c_@@_headings_cs_seq
8030+
{
8031+
\cs_if_eq:ccT { NR@ #1 } { CTEX@ #1 }
8032+
{ \cs_gset_eq:cc { @ #1 } { CTEX@ #1 } }
8033+
}
8034+
}
8035+
% \end{macrocode}
8036+
% \end{macro}
8037+
%
80098038
% \paragraph{兼容 \pkg{titlesec} 宏包}
80108039
%
80118040
% 我们修改了 \tn{@startsection} 的定义,它的第四个(\meta{beforeskip})和

0 commit comments

Comments
 (0)