summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/secnum
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-08-29 20:25:57 +0000
committerKarl Berry <karl@freefriends.org>2021-08-29 20:25:57 +0000
commite16bd0149bf77bb72427f1421046aa7ccdf1a9c5 (patch)
treeb1997f5447d292e0174b5a69e93842b56865e3f2 /Master/texmf-dist/tex/latex/secnum
parente56e35b7667194ff586da96dffe19f8174ea02e6 (diff)
secnum (29aug21)
git-svn-id: svn://tug.org/texlive/trunk@60365 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/secnum')
-rw-r--r--Master/texmf-dist/tex/latex/secnum/secnum.sty146
1 files changed, 126 insertions, 20 deletions
diff --git a/Master/texmf-dist/tex/latex/secnum/secnum.sty b/Master/texmf-dist/tex/latex/secnum/secnum.sty
index 20f75a0c800..bd0a623efda 100644
--- a/Master/texmf-dist/tex/latex/secnum/secnum.sty
+++ b/Master/texmf-dist/tex/latex/secnum/secnum.sty
@@ -30,11 +30,12 @@
%%
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
-\ProvidesExplPackage{secnum}{2020/02/02}{}
+\ProvidesExplPackage{secnum}{2021/08/28}{}
{ An intuitive way to format section numbering }
-\RequirePackage{xparse}
+\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
@@ -47,14 +48,53 @@
\else:
\int_gset:Nn \g__syu_if_thechapter_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}
+ },
+ }
+\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
- \setcounter{secnumdepth}{ \seq_count:N \l__syu_secnum_seq }
- \setcounter{tocdepth}{ \seq_count: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:
}
\cs_new_protected:Npn \__syu_secnum_unabbr:N #1
@@ -115,26 +155,92 @@
\if_cs_exist:N \thechapter
\renewcommand*{\thechapter}
{ \g__syu_chapter_tl {chapter} }
- \renewcommand*{\thesection}
- { \thechapter
- \g__syu_section_tl {section} }
+ \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} }
+ }
+ {
+ \renewcommand*{\thesection}
+ {
+ \thechapter
+ \g__syu_section_tl {section}
+ }
+ }
\else:
\renewcommand*{\thesection}
{ \g__syu_section_tl {section} }
\fi:
- \renewcommand*{\thesubsection}
- { \thesection
- \g__syu_subsection_tl {subsection} }
- \renewcommand*{\thesubsubsection}
- { \thesubsection
- \g__syu_subsubsection_tl {subsubsection} }
- \renewcommand*{\theparagraph}
- { \thesubsubsection
- \g__syu_paragraph_tl {paragraph} }
- \renewcommand*{\thesubparagraph}
- { \theparagraph
- \g__syu_subparagraph_tl {subparagraph} }
- }
+ \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: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: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}
+ }
+ }
+ }
+ }
\endinput
%%
%% End of file `secnum.sty'.