summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/secnum
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-01-01 21:54:59 +0000
committerKarl Berry <karl@freefriends.org>2020-01-01 21:54:59 +0000
commit49b5ed282c1d30b2116f5ce61c4cf134045367a9 (patch)
tree9543af4b3b1862092c37c8c92a2c03b318173716 /Master/texmf-dist/tex/latex/secnum
parent2a8c3416c9a62db3f1dd8082bb5a065dd6bfc0f8 (diff)
secnum (1jan20)
git-svn-id: svn://tug.org/texlive/trunk@53294 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/secnum')
-rw-r--r--Master/texmf-dist/tex/latex/secnum/secnum.sty139
1 files changed, 139 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/secnum/secnum.sty b/Master/texmf-dist/tex/latex/secnum/secnum.sty
new file mode 100644
index 00000000000..c3e85d464d1
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/secnum/secnum.sty
@@ -0,0 +1,139 @@
+%%
+%% This is file `secnum.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% secnum.dtx (with options: `package')
+%%
+%% Copyright (C) 2019
+%% Gau, Syu ( GauSyu@Gmail.com )
+%%
+%% ----------------------------------------------------------------------
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either
+%% version 1.3c of this license or (at your option) any later
+%% version. This version of this license is in
+%% http://www.latex-project.org/lppl/lppl-1-3c.txt
+%% and the latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of
+%% LaTeX version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is
+%% Gau, Syu ( GauSyu@Gmail.com ).
+%%
+%% ----------------------------------------------------------------------
+%%
+\NeedsTeXFormat{LaTeX2e}
+\RequirePackage{expl3}
+\ProvidesExplPackage{secnum}{2020/01/01}{}
+ { An intuitive way to format section numbering }
+\RequirePackage{xparse}
+\tl_new:N \l__syu_secnum_tl
+\seq_new:N \l__syu_secnum_seq
+\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
+\if_cs_exist:N \thechapter
+ \int_gset:Nn \g__syu_if_thechapter_int 1
+\else:
+ \int_gset:Nn \g__syu_if_thechapter_int 0
+\fi:
+\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 }
+ \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: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
+ }
+ }
+ }
+\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
+ {
+ \tl_gset:Nx \g__syu_chapter_tl
+ { \seq_item:Nn #1 { \g__syu_if_thechapter_int } }
+ \tl_gset:Nx \g__syu_section_tl
+ { \seq_item:Nn #1 { 1 + \g__syu_if_thechapter_int } }
+ \tl_gset:Nx \g__syu_subsection_tl
+ { \seq_item:Nn #1 { 2 + \g__syu_if_thechapter_int } }
+ \tl_gset:Nx \g__syu_subsubsection_tl
+ { \seq_item:Nn #1 { 3 + \g__syu_if_thechapter_int } }
+ \tl_gset:Nx \g__syu_paragraph_tl
+ { \seq_item:Nn #1 { 4 + \g__syu_if_thechapter_int } }
+ \tl_gset:Nx \g__syu_subparagraph_tl
+ { \seq_item:Nn #1 { 5 + \g__syu_if_thechapter_int } }
+ }
+\cs_new:Nn \syu_secnum:
+ {
+ \if_cs_exist:N \thechapter
+ \renewcommand*{\thechapter}
+ { \g__syu_chapter_tl {chapter} }
+ \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} }
+ }
+\endinput
+%%
+%% End of file `secnum.sty'.