summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/secnum
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-01-30 21:17:09 +0000
committerKarl Berry <karl@freefriends.org>2022-01-30 21:17:09 +0000
commit579d7d97222a51e3ff8c0c9b220dbb2cd976d52e (patch)
treefb125fce0b03476e316d61b9d922855b399efe23 /Master/texmf-dist/tex/latex/secnum
parent4ada4eeb37bcf7cc17df5ed16a3dc4581efb0d48 (diff)
secnum (30jan22)
git-svn-id: svn://tug.org/texlive/trunk@61813 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/secnum')
-rw-r--r--Master/texmf-dist/tex/latex/secnum/secnum.sty401
1 files changed, 215 insertions, 186 deletions
diff --git a/Master/texmf-dist/tex/latex/secnum/secnum.sty b/Master/texmf-dist/tex/latex/secnum/secnum.sty
index bd0a623efda..1c5aa12df30 100644
--- a/Master/texmf-dist/tex/latex/secnum/secnum.sty
+++ b/Master/texmf-dist/tex/latex/secnum/secnum.sty
@@ -29,218 +29,247 @@
%% ----------------------------------------------------------------------
%%
\NeedsTeXFormat{LaTeX2e}
-\RequirePackage{expl3}
-\ProvidesExplPackage{secnum}{2021/08/28}{}
+\RequirePackage{expl3,xparse,l3keys2e}
+\ProvidesExplPackage{secnum}{2022/01/30}{}
{ An intuitive way to format section numbering }
-\RequirePackage{xparse,l3keys2e}
-\tl_new:N \l__syu_secnum_tl
-\seq_new:N \l__syu_secnum_seq
-\int_new:N \l__syu_secnum_depth
-\tl_new:N \g__syu_chapter_tl
-\tl_new:N \g__syu_section_tl
-\tl_new:N \g__syu_subsection_tl
-\tl_new:N \g__syu_subsubsection_tl
-\tl_new:N \g__syu_paragraph_tl
-\tl_new:N \g__syu_subparagraph_tl
-\int_new:N \g__syu_if_thechapter_int
+\int_new:N \g__syu_secnum_depth
+\int_new:N \g__syu_ifchapter_int
\if_cs_exist:N \thechapter
- \int_gset:Nn \g__syu_if_thechapter_int 1
+ \int_gset:Nn \g__syu_ifchapter_int 1
\else:
- \int_gset:Nn \g__syu_if_thechapter_int 0
+ \int_gset:Nn \g__syu_ifchapter_int 0
\fi:
-\tl_new:N \g__syu_secnum_bkmr
\tl_gset:Nx \g__syu_secnum_bkmr {,}
\cs_generate_variant:Nn \tl_if_in:NnTF { NV }
\cs_generate_variant:Nn \tl_remove_all:Nn { NV }
-\keys_define:nn { syu / options }
- {
- tocdep .code:n =
- {
- \int_const:Nn \g__syu_tocdep {#1}
- \setcounter{tocdepth}{ \g__syu_tocdep }
- },
- breaking .code:n =
- {
- \tl_gset:Nx \g__syu_secnum_bkmr {#1}
- },
- }
+\tl_new:N \g__syu_chapter_tl
+\tl_new:N \g__syu_chapter_section_tl
+\tl_new:N \g__syu_section_tl
+\tl_new:N \g__syu_section_subsection_tl
+\tl_new:N \g__syu_subsection_tl
+\tl_new:N \g__syu_subsection_subsubsection_tl
+\tl_new:N \g__syu_subsubsection_tl
+\tl_new:N \g__syu_subsubsection_paragraph_tl
+\tl_new:N \g__syu_paragraph_tl
+\tl_new:N \g__syu_paragraph_subparagraph_tl
+\tl_new:N \g__syu_subparagraph_tl
+\keys_define:nn { syu / options }{
+ tocdep .code:n = {
+ \int_const:Nn \g__syu_tocdep {#1}
+ \setcounter{tocdepth}{ \g__syu_tocdep }
+ },
+ breaking .code:n = {
+ \tl_gset:Nx \g__syu_secnum_bkmr {#1}
+ },
+}
\ProcessKeysOptions{ syu / options }
-\DeclareDocumentCommand{\setsecnum}{m}
- {
- \tl_set:Nn \l__syu_secnum_tl {#1}
- \__syu_secnum_unabbr:N \l__syu_secnum_tl
- \__syu_split_by_macros:NN \l__syu_secnum_tl \l__syu_secnum_seq
- \__syu_secnum_from_seq:N \l__syu_secnum_seq
- \int_set:Nn \l__syu_secnum_depth
- {
- \seq_count:N \l__syu_secnum_seq
- }
- \setcounter{secnumdepth}
- {
- \int_eval:n
- {
- \l__syu_secnum_depth - \g__syu_if_thechapter_int
- }
- }
- \int_if_exist:NTF \g__syu_tocdep
- {
- \setcounter{tocdepth}{ \g__syu_tocdep }
- }
- {
- \setcounter{tocdepth}
- {
- \int_eval:n
- {
- \l__syu_secnum_depth - \g__syu_if_thechapter_int
- }
- }
- }
- \__syu_secnum:
+\DeclareDocumentCommand{\setsecnum}{m}{
+ \tl_set:Nn \l__syu_secnum_tl {#1}
+ \__syu_secnum_unabbr:N \l__syu_secnum_tl
+ \__syu_split_by_macros:NNN
+ \l__syu_secnum_tl \l__syu_secnum_seq \g__syu_secnum_depth
+ \__syu_secnum_from_seq:N \l__syu_secnum_seq
+ \setcounter{secnumdepth}{
+ \int_eval:n { \g__syu_secnum_depth - \g__syu_ifchapter_int }
}
-\cs_new_protected:Npn \__syu_secnum_unabbr:N #1
- {
- \regex_replace_all:nnN {A} {\c{Alph}} #1
- \regex_replace_all:nnN {a} {\c{alph}} #1
- \regex_replace_all:nnN {I} {\c{Roman}} #1
- \regex_replace_all:nnN {i} {\c{roman}} #1
- \regex_replace_all:nnN {1} {\c{arabic}} #1
+ \int_if_exist:NTF \g__syu_tocdep {
+ \setcounter{tocdepth}{ \g__syu_tocdep }
+ }{
+ \setcounter{tocdepth}{
+ \int_eval:n { \g__syu_secnum_depth - \g__syu_ifchapter_int }
+ }
}
-\cs_new_protected:Npn \__syu_split_by_macros:NN #1 #2
- {
- \tl_clear:N \l_tmpa_tl
- \seq_clear:N #2
- \tl_map_inline:Nn #1
- {
- \tl_put_right:Nn \l_tmpa_tl ##1
- \__syu_if_macro:nT ##1
- {
- \seq_put_right:NV #2 \l_tmpa_tl
- \tl_clear:N \l_tmpa_tl
- }
- }
+ \__syu_secnum:
+}
+\cs_new_protected:Npn \__syu_secnum_unabbr:N #1 {
+ \regex_replace_all:nnN {A} {\c{Alph}} #1
+ \regex_replace_all:nnN {a} {\c{alph}} #1
+ \regex_replace_all:nnN {I} {\c{Roman}} #1
+ \regex_replace_all:nnN {i} {\c{roman}} #1
+ \regex_replace_all:nnN {1} {\c{arabic}} #1
+}
+\cs_new_protected:Npn \__syu_split_by_macros:NNN #1 #2 #3 {
+ \tl_set:Nn \l_tmpa_tl {S}
+ \seq_clear:N #2
+ \int_set:Nn #3 {0}
+ \tl_map_inline:Nn #1 {
+ \__syu_if_macro:nTF ##1 {
+ \seq_put_right:NV #2 \l_tmpa_tl
+ \tl_clear:N \l_tmpa_tl
+ \tl_put_right:Nn \l_tmpa_tl ##1
+ \seq_put_right:NV #2 \l_tmpa_tl
+ \tl_clear:N \l_tmpa_tl
+ \int_incr:N #3
+ }{
+ \tl_put_right:Nn \l_tmpa_tl ##1
+ }
}
+}
\tl_new:N \g__syu_macro_tl
\tl_set:Nx \g__syu_macro_tl { \meaning \g__syu_macro_tl }
\tl_gset:Nx \g__syu_macro_tl { \tl_range:Nnn \g__syu_macro_tl {1}{5} }
-\prg_new_protected_conditional:Npnn \__syu_if_macro:n #1 { T , F , TF }
- {
- \group_begin:
- \tl_set:Nx \l_tmpa_tl {\meaning #1}
- \tl_set:Nx \l_tmpa_tl {\tl_range:Nnn \l_tmpa_tl {1} {5}}
- \exp_after:wN
- \group_end:
- \if_meaning:w \l_tmpa_tl \g__syu_macro_tl
- \prg_return_true:
- \else:
- \prg_return_false:
- \fi:
- }
-\cs_new_protected:Npn \__syu_secnum_from_seq:N #1
- {
+\prg_new_protected_conditional:Npnn \__syu_if_macro:n #1 { T , F , TF }{
+ \group_begin:
+ \tl_set:Nx \l_tmpa_tl {\meaning #1}
+ \tl_set:Nx \l_tmpa_tl {\tl_range:Nnn \l_tmpa_tl {1} {5}}
+ \exp_after:wN
+ \group_end:
+ \if_meaning:w \l_tmpa_tl \g__syu_macro_tl
+ \prg_return_true:
+ \else:
+ \prg_return_false:
+ \fi:
+}
+\cs_new_protected:Npn \__syu_secnum_from_seq:N #1 {
+ \int_if_odd:nTF \g__syu_ifchapter_int {
\tl_gset:Nx \g__syu_chapter_tl
- { \seq_item:Nn #1 { \g__syu_if_thechapter_int } }
+ { \seq_item:Nn #1 { 2 } }
+ \tl_gset:Nx \g__syu_chapter_section_tl
+ { \seq_item:Nn #1 { 3 } }
\tl_gset:Nx \g__syu_section_tl
- { \seq_item:Nn #1 { 1 + \g__syu_if_thechapter_int } }
+ { \seq_item:Nn #1 { 4 } }
+ \tl_gset:Nx \g__syu_section_subsection_tl
+ { \seq_item:Nn #1 { 5 } }
\tl_gset:Nx \g__syu_subsection_tl
- { \seq_item:Nn #1 { 2 + \g__syu_if_thechapter_int } }
+ { \seq_item:Nn #1 { 6 } }
+ \tl_gset:Nx \g__syu_subsection_subsubsection_tl
+ { \seq_item:Nn #1 { 7 } }
\tl_gset:Nx \g__syu_subsubsection_tl
- { \seq_item:Nn #1 { 3 + \g__syu_if_thechapter_int } }
+ { \seq_item:Nn #1 { 8 } }
+ \tl_gset:Nx \g__syu_subsubsection_paragraph_tl
+ { \seq_item:Nn #1 { 9 } }
\tl_gset:Nx \g__syu_paragraph_tl
- { \seq_item:Nn #1 { 4 + \g__syu_if_thechapter_int } }
+ { \seq_item:Nn #1 { 10 } }
+ \tl_gset:Nx \g__syu_paragraph_subparagrah_tl
+ { \seq_item:Nn #1 { 11 } }
\tl_gset:Nx \g__syu_subparagraph_tl
- { \seq_item:Nn #1 { 5 + \g__syu_if_thechapter_int } }
+ { \seq_item:Nn #1 { 12 } }
+ }{
+ \tl_gset:Nx \g__syu_section_tl
+ { \seq_item:Nn #1 { 2 } }
+ \tl_gset:Nx \g__syu_section_subsection_tl
+ { \seq_item:Nn #1 { 3 } }
+ \tl_gset:Nx \g__syu_subsection_tl
+ { \seq_item:Nn #1 { 4 } }
+ \tl_gset:Nx \g__syu_subsection_subsubsection_tl
+ { \seq_item:Nn #1 { 5 } }
+ \tl_gset:Nx \g__syu_subsubsection_tl
+ { \seq_item:Nn #1 { 6 } }
+ \tl_gset:Nx \g__syu_subsubsection_paragraph_tl
+ { \seq_item:Nn #1 { 7 } }
+ \tl_gset:Nx \g__syu_paragraph_tl
+ { \seq_item:Nn #1 { 8 } }
+ \tl_gset:Nx \g__syu_paragraph_subparagrah_tl
+ { \seq_item:Nn #1 { 9 } }
+ \tl_gset:Nx \g__syu_subparagraph_tl
+ { \seq_item:Nn #1 { 10 } }
}
-\cs_new:Nn \__syu_secnum:
- {
- \if_cs_exist:N \thechapter
- \renewcommand*{\thechapter}
- { \g__syu_chapter_tl {chapter} }
- \tl_if_in:NVTF \g__syu_section_tl \g__syu_secnum_bkmr
- {
- \tl_remove_all:NV \g__syu_section_tl \g__syu_secnum_bkmr
- \renewcommand*{\thesection}
- { \g__syu_section_tl {section} }
+}
+\cs_new:Nn \__syu_secnum: {
+ \if_cs_exist:N \thechapter
+ \renewcommand*{\thechapter}{ \g__syu_chapter_tl {chapter} }
+ \tl_if_in:NVTF \g__syu_chapter_section_tl \g__syu_secnum_bkmr {
+ \tl_remove_all:NV
+ \g__syu_chapter_section_tl \g__syu_secnum_bkmr
+ \renewcommand*{\thesection}{ \g__syu_section_tl {section} }
+ \makeatletter
+ \renewcommand*{\p@section}{
+ \thechapter\g__syu_chapter_section_tl
+ }
+ \renewcommand*{\p@subsection}{ \p@section}
+ \renewcommand*{\p@subsubsection}{ \p@section }
+ \renewcommand*{\p@paragraph}{ \p@section}
+ \renewcommand*{\p@subparagraph}{ \p@section }
+ \makeatother
+ }{
+ \renewcommand*{\thesection}{
+ \thechapter\g__syu_chapter_section_tl
+ \g__syu_section_tl {section}
}
- {
- \renewcommand*{\thesection}
- {
- \thechapter
- \g__syu_section_tl {section}
- }
+ }
+ \else:
+ \renewcommand*{\thesection}{ \g__syu_section_tl {section} }
+ \fi:
+ \tl_if_empty:NF \g__syu_subsection_tl {
+ \tl_if_in:NVTF \g__syu_section_subsection_tl \g__syu_secnum_bkmr {
+ \tl_remove_all:NV
+ \g__syu_section_subsection_tl \g__syu_secnum_bkmr
+ \renewcommand*{\thesubsection}{ \g__syu_subsection_tl {subsection} }
+ \makeatletter
+ \renewcommand*{\p@subsection}{
+ \p@section\g__syu_section_tl{section}
+ \g__syu_section_subsection_tl
+ }
+ \renewcommand*{\p@subsubsection}{ \p@subsection }
+ \renewcommand*{\p@paragraph}{ \p@subsection}
+ \renewcommand*{\p@subparagraph}{ \p@subsection }
+ \makeatother
+ }{
+ \renewcommand*{\thesubsection}{
+ \thesection\g__syu_section_subsection_tl
+ \g__syu_subsection_tl {subsection}
}
- \else:
- \renewcommand*{\thesection}
- { \g__syu_section_tl {section} }
- \fi:
- \tl_if_empty:NTF \g__syu_subsection_tl
- {}
- {
- \tl_if_in:NVTF \g__syu_subsection_tl \g__syu_secnum_bkmr
- {
- \tl_remove_all:NV \g__syu_subsection_tl \g__syu_secnum_bkmr
- \renewcommand*{\thesubsection}
- { \g__syu_subsection_tl {subsection} }
- }
- {
- \renewcommand*{\thesubsection}
- {
- \thesection
- \g__syu_subsection_tl {subsection}
- }
- }
- }
- \tl_if_empty:NTF \g__syu_subsubsection_tl
- {}
- {
- \tl_if_in:NVTF \g__syu_subsubsection_tl \g__syu_secnum_bkmr
- {
- \tl_remove_all:NV \g__syu_subsubsection_tl \g__syu_secnum_bkmr
- \renewcommand*{\thesubsubsection}
- { \g__syu_subsubsection_tl {subsubsection} }
- }
- {
- \renewcommand*{\thesubsubsection}
- {
- \thesubsection
- \g__syu_subsubsection_tl {subsubsection}
- }
- }
+ }
+}
+ \tl_if_empty:NF \g__syu_subsubsection_tl {
+ \tl_if_in:NVTF \g__syu_subsection_subsubsection_tl \g__syu_secnum_bkmr {
+ \tl_remove_all:NV
+ \g__syu_subsection_subsubsection_tl \g__syu_secnum_bkmr
+ \renewcommand*{\thesubsubsection}
+ { \g__syu_subsubsection_tl {subsubsection} }
+ \makeatletter
+ \renewcommand*{\p@subsubsection}{
+ \p@subsection\g__syu_subsection_tl {subsection}
+ \g__syu_subsection_subsubsection_tl
+ }
+ \renewcommand*{\p@paragraph}{ \p@subsubsection}
+ \renewcommand*{\p@subparagraph}{ \p@subsubsection }
+ \makeatother
+ }{
+ \renewcommand*{\thesubsubsection}{
+ \thesubsection\g__syu_subsection_subsubsection_tl
+ \g__syu_subsubsection_tl {subsubsection}
}
- \tl_if_empty:NTF \g__syu_paragraph_tl
- {}
- {
- \tl_if_in:NVTF \g__syu_paragraph_tl \g__syu_secnum_bkmr
- {
- \tl_remove_all:NV \g__syu_paragraph_tl \g__syu_secnum_bkmr
- \renewcommand*{\theparagraph}
- { \g__syu_paragraph_tl {paragraph} }
- }
- {
- \renewcommand*{\theparagraph}
- {
- \thesubsubsection
- \g__syu_paragraph_tl {paragraph}
- }
- }
+ }
+}
+ \tl_if_empty:NF \g__syu_paragraph_tl {
+ \tl_if_in:NVTF \g__syu_subsubsection_paragraph_tl \g__syu_secnum_bkmr {
+ \tl_remove_all:NV
+ \g__syu_subsubsection_paragraph_tl \g__syu_secnum_bkmr
+ \renewcommand*{\theparagraph}{ \g__syu_paragraph_tl {paragraph} }
+ \makeatletter
+ \renewcommand*{\p@paragraph}{
+ \p@subsubsection\g__syu_subsubsection_tl {subsubsection}
+ \g__syu_subsubsection_paragraph_tl
+ }
+ \renewcommand*{\p@subparagraph}{ \p@paragraph }
+ \makeatother
+ }{
+ \renewcommand*{\theparagraph}{
+ \thesubsubsection\g__syu_subsubsection_paragraph_tl
+ \g__syu_paragraph_tl {paragraph}
}
- \tl_if_empty:NTF \g__syu_subparagraph_tl
- {}
- {
- \tl_if_in:NVTF \g__syu_subparagraph_tl \g__syu_secnum_bkmr
- {
- \tl_remove_all:NV \g__syu_subparagraph_tl \g__syu_secnum_bkmr
- \renewcommand*{\thesubparagraph}
- { \g__syu_subparagraph_tl {subparagraph} }
- }
- {
- \renewcommand*{\thesubparagraph}
- {
- \theparagraph
- \g__syu_subparagraph_tl {subparagraph}
- }
- }
+ }
+}
+ \tl_if_empty:NF \g__syu_subparagraph_tl {
+ \tl_if_in:NVTF \g__syu_paragraph_subparagrah_tl \g__syu_secnum_bkmr {
+ \tl_remove_all:NV
+ \g__syu_paragraph_subparagrah_tl \g__syu_secnum_bkmr
+ \renewcommand*{\thesubparagraph}{ \g__syu_subparagraph_tl {subparagraph} }
+ \makeatletter
+ \renewcommand*{\p@subparagraph}{
+ \p@paragraph\g__syu_paragraph_tl {paragraph}
+ \g__syu_paragraph_subparagrah_tl
+ }
+ \makeatother
+ }{
+ \renewcommand*{\thesubparagraph}{
+ \theparagraph\g__syu_paragraph_subparagrah_tl
+ \g__syu_subparagraph_tl {subparagraph}
}
- }
+ }
+ }
+}
\endinput
%%
%% End of file `secnum.sty'.