summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/secnum/secnum.dtx
blob: b8309f8c4d43b09c339f799659911d40d8e599b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
% \iffalse meta-comment
%
% 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 ).
%
% ----------------------------------------------------------------------
%
%<*internal>
\iffalse
%</internal>
%<*readme>

# secnum

This package provides a macro `\setsecnum` to format section numbering intuitively.

## Usage

One can simply use `\setsecnum{A,1.i}` to set the section numbering
format as `Alph` for the sections, `arabic` for the subsections and 
`arabic.roman` for the subsubsections and 
the `secnumdepth` and `tocdepth` will be 3. 

If one want to set the tocdepth manually, 
there is an option `tocdep` for it.

One may notice that the comma `,` plays a special role in the numbering format:
for deep levels, the numbering before the comma are hided.

## Installation

The installation is the same as usual Tex packages.

0. Put the source file `secnum.dtx` in a empty folder and go to there.

1. Run the following to create the package file `secnum.sty` (as well as this file `README.md`)

       pdfTeX secnum.dtx

2. Move the following file into proper directories searched by TeX.
   The recommended directory is

       tex/latex/secnum

3. To produce the documentation run the following

       pdfLaTeX secnum.dtx

4. The recommended directory for the documentation is

       doc/latex/secnum

## Download

One can also download the generated files from the [github release](https://github.com/GauSyu/secnum/releases).

%</readme>
%<*internal>
\fi
\begingroup
  \def\nameoflatexe{LaTeX2e}
\expandafter\endgroup\ifx\nameoflatexe\fmtname\else
\csname fi\endcsname
%</internal>
%<*install>

\input docstrip.tex

\preamble

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 ).
 
----------------------------------------------------------------------

\endpreamble

\keepsilent

\generate{
  \usedir{tex/latex/secnum}
  \file{\jobname.sty}{\from{\jobname.dtx}{package}}
  \nopreamble\nopostamble
  \file{README.md}{\from{\jobname.dtx}{readme}}
}
\Msg{*************************************************************}
\Msg{*                                                           *}
\Msg{* To finish the installation you have to move the following *}
\Msg{* file into proper directories searched by TeX:             *}
\Msg{*                                                           *}
\Msg{* The recommended directory is TDS:tex/latex/secnum         *}
\Msg{*                                                           *}
\Msg{*     secnum.sty                                            *}
\Msg{*                                                           *}
\Msg{* To produce the documentation run the file secnum.dtx      *}
\Msg{* through XeLaTeX.                                          *}
\Msg{*                                                           *}
\Msg{* Happy TeXing!                                             *}
\Msg{*                                                           *}
\Msg{*************************************************************}
\endbatchfile
%</install>
%<*internal>
\fi
%</internal>
%<*driver>
\ProvidesFile{secnum.dtx}
\documentclass{l3doc}
\usepackage{indentfirst}
\usepackage{booktabs}
\usepackage{xcolor}
\usepackage[tocdep=2]{secnum}
\setsecnum{A,1.i}
\ExplSyntaxOn
\cs_set_eq:NN \__codedoc_macro_end_style:n \use_none:n
\ExplSyntaxOff
\DeclareRobustCommand \opt {\texttt}
\def\glossaryname{Changes History}
\GlossaryPrologue{\section{\glossaryname}}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{\jobname.dtx}
  \PrintChanges
\end{document}
%</driver>
% \fi
% \GetFileInfo{\jobname.sty}
% \DoNotIndex{\cs}
%
% \title{ The \pkg{\jobname} package }
% \author{ Gau, Syu }
% \date{ \textit{Last Update:} \filedate }
%
% \maketitle
%
% \begin{abstract}
%   The package \pkg{\jobname} provides a marco \cs{setsecnum} 
%   which allows user to format section numbering intuitively.
% \end{abstract}
%
% \tableofcontents
% \begin{documentation}
%
% \section{Example}
%    This document uses the following setting of section numbering format.
%  \begin{verbatim}
%    \usepackage[tocdep=2]{secnum}
%    \setsecnum{A,1.i}
%  \end{verbatim}
%
% \section{Usage}
%   Before using the macro, load the package in preamble.
%  \begin{verbatim}
%    \usepackage{secnum}
%  \end{verbatim}
%
% \subsection{Set numbering format} 
%   One can format the section numbering by using the 
%   marco \cs{setsecnum} in preamble.
%  \begin{function}{\setsecnum}
%  \begin{syntax}
%    \cs{setsecnum}\marg{num format}
%  \end{syntax}
%
%    A typical \meta{num format} is like this:
%  \begin{center}
%    \verb|A,1.i|
%  \end{center}
%    It consists of some syntax abbrs of numbering formats, 
%    reffering the follows,
%  \begin{center}
%   \begin{tabular}{ccccc}
%    \toprule
%     A & a & I & i & 1 \\
%    \midrule
%     \cs{Alph} & \cs{alph} & \cs{Roman} & \cs{roman} & \cs{arabic} \\
%    \bottomrule
%   \end{tabular}
%  \end{center}
%   and some separators delimiting them. 
%
%   The separators can be any character except above abbrs, 
%   the tokens ``\verb|{|'', ``\verb|}|'' and ``\verb|#|''
%   (more precisely, explicit character tokens with category code
%   1 (begin-group) or 2 (end-group), and tokens with category code 6) and the space ``\verb*| |''.
%
%   Note that \meta{num format} must end with an abbr.
%
%    \begin{texnote}
%      This command will overwrite 
%      \opt{secnumdepth} and \opt{tocdepth}
%    \end{texnote}
%  \end{function}
%  
% \subsection{Breaking the numbering}
%    The comma ``\verb|,|'' in above example is used as the breaking mark:
%    for deep levels (in our case, deeper than sections), 
%    the numbering before ``\verb|,|'' will be hided.
%
%    Note that the breaking mark must immediately follows an abbr.
%
% \subsection{Package options}
% \subsubsection{tocdep}
%   There is an option setting \opt{tocdepth}, the table-of-contents depth manually.
%  \begin{function}{ tocdep }
%    \begin{syntax}
%      \opt{tocdep} = \meta{integer}
%    \end{syntax}
%
%    The \meta{integer} refers to the table-of-contents depth, 
%    which should between $1$ and $5$. 
%
%    \begin{texnote}
%      If this option is used, then \cs{setsecnum} will not overwrite \opt{tocdepth}.
%    \end{texnote}
%  \end{function}
%
% \subsubsection{breaking}
%    Another option is used to change the breaking mark.
%  \begin{function}{ breaking }
%    \begin{syntax}
%      \opt{breaking} = \meta{token}
%    \end{syntax}
%
%    The \meta{token} will be the breaking mark 
%    (the default is the comma ``\verb|,|''). 
%    It can be any character except above abbrs, 
%    the tokens ``\verb|{|'', ``\verb|}|'' and ``\verb|#|''
%    (more precisely, explicit character tokens with category code
%    1 (begin-group) or 2 (end-group), and tokens with category code 6) and the space ``\verb*| |''.
%  \end{function}
%
% \section{Process}
%   The process of the macro \cs{setsecnum} can be 
%   explained as follows.
% \begin{enumerate}[label=Step \arabic*.]
%   \item The main function eats the input, saying \opt{A,1.i}, 
%         and stores it in a token list.
%   \item Replace abbrs by macros.
%         In our example, it results 
%         ``\cs{Alph}\opt{,}\cs{arabic}\opt{.}\cs{roman}''
%   \item Split this token list into a sequence by macros. 
%         In our example, it results ``\cs{Alph}'', 
%         ``\opt{,}\cs{arabic}'' and ``\opt{.}\cs{roman}''.
%   \item Store those codes in indivial containers.
%   \item Detect if there is \cs{thechapter}. 
%         Skip the chapter level if not.
%         In our example, this is the case. 
%   \item Use the containers to redefine 
%         \cs{thesection}, \cs{thesubsection}, 
%         \cs{thesubsubsection} etc. 
%         In each step, detect if such level needs numbering and
%         if there is a breaking mark in the container.
%         In our example, the numbering formats will be redefined as 
% \end{enumerate}
%  \begin{verbatim}
%    \renewcommand*{\thesection}{\Alph{section}}
%    \renewcommand*{\thesubsection}{\arabic{subsection}}
%    \renewcommand*{\thesubsubsection}{thesubsection.\roman{subsubsection}}
%  \end{verbatim}
%   
% \end{documentation}
%
% \StopEventually{}
% 
% \begin{implementation}
% \section{Implementation}
%   The following is the implementation. 
%   Users can ignore.
% \subsection{Preparations}
%   This package uses \LaTeX3. 
%   Therefore, the packages \pkg{expl3}, \pkg{xparse} and \pkg{l3keys2e}
%   are needed and should use 
%   \cs{ProvidesExplPackage} rather than \cs{ProvidesPackage}.
%
%    \begin{macrocode}
%<*package>
%<@@=syu>
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
\ProvidesExplPackage{secnum}{2021/08/28}{}
  { An intuitive way to format section numbering }
\RequirePackage{xparse,l3keys2e}
%    \end{macrocode}
%
%  \begin{variable}{ \l__syu_secnum_tl, \l__syu_secnum_seq }
%   The variables are used to store the formatting information.
%    \begin{macrocode}
\tl_new:N \l__syu_secnum_tl
\seq_new:N \l__syu_secnum_seq
\int_new:N \l__syu_secnum_depth
%    \end{macrocode}
%  \end{variable}
%
%  \begin{variable}{ 
%    \g__syu_chapter_tl, 
%    \g__syu_section_tl,
%    \g__syu_subsection_tl,
%    \g__syu_subsubsection_tl,
%    \g__syu_paragraph_tl,
%    \g__syu_subparagraph_tl
%   }
%   The following variables are used to store 
%   the individal formatting codes.
%    \begin{macrocode}
\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
%    \end{macrocode}
%  \end{variable}
%
%  \begin{variable}{ \g__syu_if_thechapter_int }
%   This \meta{integer} encodes if \cs{thechapter} is defined.
%    \begin{macrocode}
\int_new:N \g__syu_if_thechapter_int
%    \end{macrocode}
%   If \cs{thechapter} is defined, it is $1$.
%    \begin{macrocode}
\if_cs_exist:N \thechapter
  \int_gset:Nn \g__syu_if_thechapter_int 1
%    \end{macrocode}
%   Otherwise, it is $0$.
%    \begin{macrocode}
\else:
  \int_gset:Nn \g__syu_if_thechapter_int 0
\fi:
%    \end{macrocode}
%  \end{variable}
%
%  \begin{variable}{ \l__syu_secnum_bkm }
%   This variable is used to store the breaking mark.
%    \begin{macrocode}
\tl_new:N \g__syu_secnum_bkmr
\tl_gset:Nx \g__syu_secnum_bkmr {,}
%    \end{macrocode}
%   Note that one needs the following variants
%    \begin{macrocode}
\cs_generate_variant:Nn \tl_if_in:NnTF { NV }
\cs_generate_variant:Nn \tl_remove_all:Nn { NV }
%    \end{macrocode}
%  \end{variable}
%
%   \changes{2020/01/12}{2020/01/12}{Add package option to set \opt{tocdepth}.}
% \subsection{Package option}
%    \begin{macrocode}
\keys_define:nn { syu / options }
  {
%    \end{macrocode}
%
%  \begin{macro}{ tocdep }
%   Set the table-of-contents depth.
%    \begin{macrocode}
    tocdep .code:n = 
      { 
        \int_const:Nn \g__syu_tocdep {#1} 
        \setcounter{tocdepth}{ \g__syu_tocdep }
      },
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{ breaking }
%   Set the breaking mark used in \meta{num format}.
%    \begin{macrocode}
    breaking .code:n = 
      { 
        \tl_gset:Nx \g__syu_secnum_bkmr {#1} 
      },
%    \end{macrocode}
%  \end{macro}
%
%    \begin{macrocode}
  }
%    \end{macrocode}
%
%   Passing keys to options.
%    \begin{macrocode}
\ProcessKeysOptions{ syu / options }
%    \end{macrocode}
%
% \subsection{Main function}
%  \begin{macro}{\setsecnum}
%   Here is the definition of the main function \cs{setsecnum}.
%    \begin{macrocode}
\DeclareDocumentCommand{\setsecnum}{m}
  {
%    \end{macrocode}
%   Store the input in.
%    \begin{macrocode}
    \tl_set:Nn \l__syu_secnum_tl {#1}
%    \end{macrocode}
%   Replace syntax abbrs by corresponding macros.
%    \begin{macrocode}
    \__syu_secnum_unabbr:N \l__syu_secnum_tl
%    \end{macrocode}
%   Split into a sequence by macros.
%    \begin{macrocode}
    \__syu_split_by_macros:NN \l__syu_secnum_tl \l__syu_secnum_seq
%    \end{macrocode}
%   Read formatting information.
%    \begin{macrocode}
    \__syu_secnum_from_seq:N \l__syu_secnum_seq
%    \end{macrocode}
%   Set the \opt{secnumdepth} and \opt{tocdepth}.
%   \changes{2020/01/12}{2020/01/12}{Add codes to set \opt{tocdepth}.}
%    \begin{macrocode}
    \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 
              } 
          }
      }
%    \end{macrocode}
%   Format numberings.
%    \begin{macrocode}
    \__syu_secnum:
  }
%    \end{macrocode}
%  \end{macro}
%
% \subsection{Unabbravation}
%  \begin{variable}{ \__syu_secnum_unabbr:N }
%   This function replace the abbrs in a \meta{tl var}  
%   by expansions.
%    \begin{macrocode}
\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
  }
%    \end{macrocode}
%  \end{variable}
%
% \subsection{Split to sequence}
%  \begin{variable}{ \__syu_split_by_macros:NN }
%   This function split a \meta{tl var} into a \meta{sequence} 
%   by macros.
%    \begin{macrocode}
\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
          }
      }
  }
%    \end{macrocode}
%  \end{variable}
%   But how to see if an \meta{item} in the token list is a macro?
%  \begin{variable}{ \g__syu_macro_tl }
%   This \meta{tl var} stores the first five characters 
%   of the meaning of any macro, 
%   i.e. \opt{macro} (watch out its catcode). 
%   The idea is to creat a \meta{tl var} and then set 
%   its value to be the first five characters of its meaning.
%    \begin{macrocode}
\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} }
%    \end{macrocode}
%  \end{variable}
%  \begin{variable}{ \__syu_if_macro:nT, 
%  \__syu_if_macro:nF, \__syu_if_macro:nTF, }
%   Then, define a conditional testing if the input is a macro. 
%   Note that I use \cs{if_meaning} rather than \cs{tl_if_eq:NNTF}.
%    \begin{macrocode}
\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}}
%    \end{macrocode}
%   This is a trick to keep \cs{l_tmpa_tl} in the current local group
%    \begin{macrocode}
    \exp_after:wN
    \group_end:
%    \end{macrocode}
%   while throwing the comparison result out.
%    \begin{macrocode}
      \if_meaning:w \l_tmpa_tl \g__syu_macro_tl
        \prg_return_true:
      \else:
        \prg_return_false:
      \fi:
  }
%    \end{macrocode}
%  \end{variable}
%
% \subsection{Read formatting info}
%  \begin{variable}{ \__syu_secnum_from_seq:N  }
%   Read the formatting info from given \meta{sequence}.
%    \begin{macrocode}
\cs_new_protected:Npn \__syu_secnum_from_seq:N #1
  {
%    \end{macrocode}
%   Use \cs{tl_gset:Nx} since: 1, these data are global and 
%   2: I need them eating the fully expanded results.
%    \begin{macrocode}
    \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 } }
  }
%    \end{macrocode}
%  \end{variable}
%
% \subsection{Formatting}
%  \begin{variable}{ \__syu_secnum:  }
%   Formatting section numbering.
%    \begin{macrocode}
\cs_new:Nn \__syu_secnum: 
  {
%    \end{macrocode}
% \subsubsection{Detect if there is \cs{thechapter}}\noindent
%   When \cs{thechapter} is defined, start from it.
%    \begin{macrocode}
    \if_cs_exist:N \thechapter
      \renewcommand*{\thechapter}
        { \g__syu_chapter_tl {chapter} }
%    \end{macrocode}
%   Test if the numbering breaks before section.
%    \begin{macrocode}
    \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} 
          }
      }
%    \end{macrocode}
%   Otherwise start from \cs{thesection}.
%    \begin{macrocode}
    \else:
      \renewcommand*{\thesection}
        { \g__syu_section_tl {section} }
    \fi:
%    \end{macrocode}
%
%   \changes{2021/08/28}{2021/08/28}{The usage of breaking commas}
% \subsubsection{Subsections}\noindent
%   Test if the subsections are needed to be numbered.
%    \begin{macrocode}
    \tl_if_empty:NTF \g__syu_subsection_tl
      {}
      {
%    \end{macrocode}
%   Test if the numbering breaks before subsection.
%    \begin{macrocode}
        \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} 
              }
          }
      }
%    \end{macrocode}
%
% \subsubsection{Subsubsections}\noindent
%   Test if the subsubsections are needed to be numbered.
%    \begin{macrocode}
    \tl_if_empty:NTF \g__syu_subsubsection_tl
      {}
      {
%    \end{macrocode}
%   Test if the numbering breaks before subsubsection.
%    \begin{macrocode}
        \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} 
              }
          }
      }
%    \end{macrocode}
%
% \subsubsection{Paragraphs}\noindent
%   Test if the paragraphs are needed to be numbered.
%    \begin{macrocode}
    \tl_if_empty:NTF \g__syu_paragraph_tl
      {}
      {
%    \end{macrocode}
%   Test if the numbering breaks before paragraph.
%    \begin{macrocode}
        \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} 
              }
          }
      }
%    \end{macrocode}
%
% \subsubsection{Subparagraphs}\noindent
%   Test if the subparagraphs are needed to be numbered.
%    \begin{macrocode}
    \tl_if_empty:NTF \g__syu_subparagraph_tl
      {}
      {
%    \end{macrocode}
%   Test if the numbering breaks before paragraph.
%    \begin{macrocode}
        \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} 
              }
          }
      }
   }
%    \end{macrocode}
%  \end{variable}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%\end{implementation}
%
%
% \changes{2020/01/01}{2020/01/01}{Correct the package name.}
%
% \Finale
\endinput