summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/xcntperchap/xcntperchap_doc.tex
blob: 31fe1df3e9140b764e4d9b38dc88f94d2b2a4de9 (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
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
%% LaTeX package xcntperchap - version 0.5 (2018/01/05 -- 22:04:12)
%% Documentation file for xcntperchap.sty
%%
%%
%% -------------------------------------------------------------------------------------------
%% Copyright (c) 2016 -- 2018 by Dr. Christian Hupfer <typography dot with dot latex at gmail dot com>
%% -------------------------------------------------------------------------------------------
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% 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 `author-maintained`
%%
%%

\documentclass[12pt,a4paper]{article}




\usepackage[lmargin=2cm,rmargin=2cm,headheight=15pt]{geometry}
\usepackage{savesym}
\usepackage{bbding}
\savesymbol{Cross}

\usepackage{graphicx}
\usepackage{blindtext}
\usepackage[x11names]{xcolor}
\usepackage{imakeidx}
\usepackage{fontawesome}
\usepackage[most,documentation]{tcolorbox}
\usepackage[tikz]{bclogo}
\usepackage{marginnote}
\usepackage{fancyhdr}
\usepackage{datetime}
\usepackage{array}
\usepackage{xkeyval}
\usepackage{xparse}
\usepackage{totcount}
\usepackage{enumitem}
\usepackage{microtype}
\usepackage{caption}
\usepackage[T1]{fontenc}
\usepackage[scaled=0.92]{helvet}

\newlist{codeoptionsenum}{enumerate}{1}
\setlist[codeoptionsenum,1]{label={\textcolor{blue}{\#\arabic*}}}

\renewcommand{\rmdefault}{\sfdefault}

\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}

\makeatletter
\define@key{chdoc}{packageauthor}{%
  \def\KVchdocpackageauthor{#1}%
}

\define@key{chdoc}{packageauthormail}{%
  \def\KVchdocpackageauthormail{#1}%
}

\define@key{chdoc}{filepurpose}{%
  \def\KVchdocfilepurpose{#1}%
}


\newcommand{\chdocextractversion}[1]{%
  \@nameuse{#1}%
}


\@namedef{xcntperchapversion0.1}{v0.1 2016-05-22}
\@namedef{xcntperchapversion0.2}{v0.2 2016-06-07}

\@namedef{xcntperchapversion0.3}{v0.3 2017-01-09}

\@namedef{xcntperchapversion0.4}{v0.4 2017-04-19}


\@namedef{xcntperchapversion0.5}{v0.5 2018-01-05}

\newcommand{\authorname}{Autor}


\makeatother






\fancypagestyle{plain}{%
\fancyfoot[L]{\begin{tabular}[t]{l}\PackageDocName\ \packageversion \tabularnewline \textcopyright\ Dr. Christian Hupfer\end{tabular}}%
\fancyfoot[C]{\thepage}%
\fancyfoot[R]{\today}%
\renewcommand{\headrule}{{\color{blue}%
\hrule width\headwidth height\headrulewidth \vskip-\headrulewidth}}
\renewcommand{\footrule}{{\color{blue}\vskip-\footruleskip\vskip-\footrulewidth
\hrule width\headwidth height\footrulewidth\vskip\footruleskip}}
\renewcommand{\footrulewidth}{2pt}
\renewcommand{\headrulewidth}{2pt}
}



\newtcolorbox{CHPackageTitleBox}[1][]{%
  enhanced jigsaw,
  drop lifted shadow,
  colback=yellow!30!white,
  width=0.8\textwidth,
  #1
}

\presetkeys{chdoc}{packageauthor={Christian Hupfer}}{}%
\NewDocumentCommand{\CHPackageTitlePage}{O{}mO{}}{%
  \setkeys{chdoc}{packageauthor={Christian Hupfer},filepurpose={Documentation},#1}%
  \begin{center}
    \begin{CHPackageTitleBox}[#3]
      \large \bfseries%
      \begin{center}%
        \begin{tabular}{C{0.9\textwidth}}%
          \scshape \PackageDocName \tabularnewline
          \tabularnewline
          #2 \tabularnewline
          \tabularnewline
          \KVchdocfilepurpose \tabularnewline
          \tabularnewline
          Version \packageversion \tabularnewline
          \tabularnewline
          \today \tabularnewline
          \tabularnewline
          \addtocounter{footnote}{2}
          \authorname: \KVchdocpackageauthor\(^\mathrm{\fnsymbol{footnote}}\)
          \tabularnewline
        \end{tabular}
      \end{center}
    \end{CHPackageTitleBox}
    \renewcommand{\thefootnote}{\fnsymbol{footnote}}%
    \footnotetext{\mymailtoaddress}%
  \end{center}
}

\newtcolorbox{docCommandArgs}[1]{colbacktitle={blue},coltitle={white},title={Description of arguments of command \cs{#1}}}


\newcommand{\tcolorboxdoclink}{http://mirrors.ctan.org/macros/latex/contrib/tcolorbox/tcolorbox.pdf}

% 'Stolen' from tcolorbox documentation ;-)

\newtcolorbox{marker}[1][]{enhanced,
  before skip=2mm,after skip=3mm,
  boxrule=0.4pt,left=5mm,right=2mm,top=1mm,bottom=1mm,
  colback=yellow!50,
  colframe=yellow!20!black,
  sharp corners,rounded corners=southeast,arc is angular,arc=3mm,
  underlay={%
    \path[fill=tcbcol@back!80!black] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
    \path[draw=tcbcol@frame,shorten <=-0.05mm,shorten >=-0.05mm] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
    \path[fill=yellow!50!black,draw=none] (interior.south west) rectangle node[white]{\Huge\bfseries !} ([xshift=4mm]interior.north west);
    },
    drop fuzzy shadow,#1}


%%%% Documentation macros


\NewDocumentCommand{\packagename}{sm}{%
  \textcolor{blue}{\textbf{\faEnvelopeO~#2}}%
  \IfBooleanF{#1}{%
    \index{Package!#2}
  }%
}

\NewDocumentCommand{\classname}{sm}{%
  \textcolor{brown}{\textbf{\faBriefcase~#2}}%
  \IfBooleanF{#1}{%
    \index{Package!#2}%
  }%
}


\NewDocumentCommand{\CHDocPackage}{sm}{%
  \textcolor{blue}{\textbf{\faEnvelopeO~#2}}%
  \IfBooleanF{#1}{%
    \index{Package!#2}
  }%
}




\NewDocumentCommand{\CHDocClass}{sm}{%
  \textcolor{brown}{\textbf{\faBriefcase~#2}}%
  \IfBooleanF{#1}{%
    \index{Package!#2}%
  }%
}

\NewDocumentCommand{\CHDocKey}{sm}{%
  \textcolor{red}{\textbf{\faKey~#2}}%
  \IfBooleanF{#1}{%
      \index{Option!#2}%
  }%
}

\newcommand{\handrightnote}{\tcbdocmarginnote{\ding{43}}}


\NewDocumentCommand{\CHDocCounter}{sm}{%
  \textcolor{Green4}{\textbf{\faCalculator~#2}}%
  \IfBooleanF{#1}{%
    \index{Counter!#2}%
  }%	
}


\NewDocumentCommand{\CHDocTag}{sm}{%
  \textcolor{violet}{\faTag~#2}%
  \IfBooleanF{#1}{%
    \index{Feature!#2}%
  }%	
}


\NewDocumentCommand{\CHDocFileExt}{sm}{%
    \faFile~#2%
}

\NewDocumentCommand{\CHDocFiles}{sm}{%
    \faFilesO~#2%
}


\NewDocumentCommand{\CHDocConventions}{}{%
  \section*{\centering Typographical conventions}
  Throughout this documentation following symbols and conventions are used:
  \begin{itemize}
  \item \CHDocClass*{foo} means a the class \texttt{foo}
  \item \CHDocPackage*{foo} names a package \texttt{foo}
  \item \CHDocCounter*{foo} indicates a counter named \texttt{foo}
  \item \CHDocFileExt*{foo} will indicate either a file named \texttt{foo} or a file extension \texttt{foo}
  \item \CHDocFiles*{foo} will indicate some files 
  \item \CHDocTag*{foo} names a special feature or tag \texttt{foo}
  \item \CHDocKey*{foo} deals with a command or package option named \texttt{foo}
  \end{itemize}
}



\renewcommand{\tcbdocnew}[1]{#1}%
\renewcommand{\tcbdocupdated}[1]{#1}%

\newcommand{\CHDocNew}[1]{%
  \tcbdocmarginnote[doclang/new={N},
  colframe=blue,
  halign=left,
  colback={blue!20!white},
  fontupper={\tiny}
  ]{%
    \chdocextractversion{xcntperchapversion#1}%
  }%
}



\newcommand{\CHDocUpdate}[1]{\tcbdocmarginnote[doclang/updated={},colback={yellow},colframe={yellow!50!red},  fontupper={\tiny}
]{%
  \tcbdocupdated{\chdocextractversion{xcntperchapversion#1}}%
}%
}



\newcommand{\CHDocFullVersion}[1]{Version \chdocextractversion{xcntperchapversion#1}}


\newcommand{\CHDocExpCommand}[1][Expandable]{%
  \tcbdocmarginnote[doclang/new={N},
  colframe=green!50!blue,
  halign=left,
  colback={green!90!blue},
  fontupper={\tiny}
  ]{%
    #1%
  }%
}


\newcommand{\CHDocExperimentalFeature}[1][Experimental]{%
  \tcbdocmarginnote[doclang/new={N},
  colframe=yellow!50!blue,
  halign=left,
  colback={blue!10!yellow},
  fontupper={\tiny}
  ]{%
    #1%
  }%
}




\usepackage{xcntperchap}
\usepackage{cleveref}

\newcommand{\PackageDocName}{xcntperchap}%

\newcommand{\mymailtoaddress}{%
  typography.with.latex@gmail.com
}


\def\packageversion{\xcntperchappackageversion}%

\makeindex[intoc]

\RegisterTrackCounter{section}{subsection,subsubsection,table,figure}

\hypersetup{breaklinks=true}



\hypersetup{breaklinks=true,
  pdftitle={\jobname.pdf -- version \packageversion},
  pdfauthor={Dr. Christian Hupfer},
  pdfsubject={Documentation of \PackageDocName\ package},
  pdfkeywords={LaTeX, counters},
  pdfcreator={LaTeX}
}


\begin{document}
\mmddyyyydate


\setlength{\parindent}{0pt}

\thispagestyle{empty}%
\CHPackageTitlePage[packageauthor={Christian Hupfer}]{Store counter values per chapter (or other track levels)}
\clearpage
\tableofcontents
\clearpage

\CHDocConventions
\clearpage

\pagestyle{plain}

\setcounter{footnote}{0}

\pagestyle{plain}



\section{Disclaimer}
This package as of its version \packageversion\ is a rewrite of the former \CHDocPackage{cntperchap} by the same author, is under constant development and as such subject to macro interface changes as well as renaming of macros. Not all features of the previous package has been incorporated so far -- if some functionality of your document depends on \CHDocPackage{assoccnt}, continue using the older version and shift gradually to \CHDocPackage{\PackageDocName} please, which uses the newer \CHDocPackage{xassoccnt}. 

\begin{marker}
Most times class and package authors will benefit of this package, but there might be usual documents that need the features of |\PackageDocName||
\end{marker}

\section{Introduction}

The aim of this package is to provide support for a summary in advance how many sections, subsections, etc. or figures, tables, equations there will be in predefined track level, for example per chapters. The values are stored at the beginning of such a new track level, say \cs{chapter} and written to a \CHDocFileExt{jobname.cpc} file.

\begin{marker}
  Since the \CHDocCounter*{page} counter is an unrealiable 'friend' it is not advised to use this counter as a track level. 
\end{marker}


As of version \packageversion\ there is no default version of a track level.

This package is the consequence of the question \url{http://tex.stackexchange.com/questions/241559/how-to-count-the-total-number-of-sections-within-a-chapter} by the user \texttt{gsl}. 



\section{Package options}%
\label{section::package_options}

As of version \packageversion~ the package has no package options.


\section{Requirements and incompatibilities}%

\subsection{Required packages}

Since \CHDocPackage{\PackageDocName} is written using \CHDocPackage{expl3}, it requires the \CHDocPackage{xparse} package. It relies on the features of associated counters introduced by \CHDocPackage{xassoccnt} v1.4. 

\begin{itemize}
\item \CHDocPackage{zref}%
\item \CHDocPackage{expl3}%
\item \CHDocPackage{xparse}%
\item \CHDocPackage{xassoccnt}%
\end{itemize}

The package \CHDocPackage{xparse} is already loaded by \CHDocPackage{assoccnt} and does not need to be specified again. 

\subsection{Incompatibilities}

This package has been tested with the standard classes \classname{article}, \classname{book} and \classname{report} as well as with \classname{memoir} and the relevant \classname{KOMA} equivalents. As of version \packageversion\ for those classes there are no known incompatibilities with the general behaviour of the package, however, there is an issue with \CHDocPackage{assoccnt} and \CHDocPackage{xifthen} which is not solved so far. 

\marginnote{\bcbombe} It would be nice to adapt the package for usage on a per frame base with the \classname{beamer} class, but this seems both not really necessary as well as quite difficult, since \classname{beamer} follows different strategies about the usage of ``pages'' or ``sections'', see \ref{section::todo}


\clearpage


\section{Documentation of Macros}

\subsection{Preamble only commands}

\begin{docCommand}{RegisterTrackCounter}{\marg{track counter}\marg{counter1, counter2,...}} \CHDocNew{0.3}

This provides the means to let the package know that the counters should be tracked for values inside a certain track level -- specify this in the document preamble.

\begin{docCommandArgs}{RegisterTrackCounter}%
  \begin{itemize}
  \item \marg{track counter}
    This contains the counter name which is the track level, e.g. \CHDocCounter*{section}
  \item \marg{counter1, counter2,...}
    This marks the counters to be tracked inside the track level, e.g. \CHDocCounter*{subsection}, \CHDocCounter*{subsubsection}
\end{itemize}
\end{docCommandArgs}

\end{docCommand}%



\begin{docCommand}{RegisterMultipleTrackCounters}{\marg{track counter 1, track counter 2,...}\marg{counter1, counter2,...}} \CHDocNew{0.3}

This provides the means to let the package know that the counters should be tracked for values inside multiple track levels -- specify this in the document preamble.

All counters in the 2nd mandatory argument will be tracked by \textbf{all} track levels. 

\begin{docCommandArgs}{RegisterMultipleTrackCounters}%
  \begin{itemize}
  \item \marg{track level 1, track level 2,...}
    This list contains the counters which are track levels
  \item \marg{counter1, counter2,...}
    This marks the counters to be tracked inside of each(!) track level.
\end{itemize}
\end{docCommandArgs}

\end{docCommand}%



\begin{docCommand}{RegisterCounters}{\marg{track counter}\marg{counter1, counter2,...}} \tcbdocmarginnote{\tcbdocnew{\chdocextractversion{xcntperchapversion0.1}}}

\refCom{RegisterCounters} has the some meaning like \refCom{RegisterTrackCounter} and is the old name for this. Use the newer version for new documents since this command will be removed one day.
\end{docCommand}%



\section{User commands}


\begin{docCommand}[doc new={\chdocextractversion{xcntperchapversion0.1}}]{ObtainTrackedValue}{\oarg{counter value}\marg{track level}\marg{tracked counter}}% \tcbdocmarginnote{\tcbdocnew{\chdocextractversion{xcntperchapversion0.1}}}

This command prints the value of the tracked counter of a track counter, i.e. the number of subsections in a specific chapter, say, the 5th chapter can be obtained by

\begin{dispExample}{listings only}
  \ObtainTrackedValue[5]{chapter}{subsection}
\end{dispExample}

\begin{codeoptionsenum}
  \item \oarg{options}: As of version \packageversion, the only option is a counter value, say 5 for the 5th chapter. This must be the total number of the relevant track counter, i.e. the 17th total section etc. 
  \item \marg{track counter name}: The name of the track level, i.e. \CHDocCounter*{section}. 
  \item \marg{tracked counter name}: The name of the tracked counter, i.e. \CHDocCounter*{figure}. 
\end{codeoptionsenum}

Please note that the number of entities per track level might be reported wrongly for floats, since those are shifted to some other places. If this should be prevented, a \cs{FloatBarrier} from \CHDocPackage{placeins} might be necessary (see the example file \verb!xcntperchap_driver.tex!)

\begin{marker}\tcbdocmarginnote{\tcbdocupdated{\chdocextractversion{xcntperchapversion0.2}}}
  This macro is not expandable -- for an expandable version use \refCom{ObtainTrackedValueExp} instead.
\end{marker}

\end{docCommand}

\begin{docCommand}[before={\CHDocExpCommand}]{ObtainTrackedValueExp}{\oarg{counter value}\marg{track level}\marg{tracked counter}} \tcbdocmarginnote{\tcbdocnew{\chdocextractversion{xcntperchapversion0.2}}}

This command is the expandable version of \refCom{ObtainTrackedValue} and should be used if calculations, comparisions and write - operations to files are requested.

The meaning of arguments is the same as in \refCom{ObtainTrackedValue}. 
\end{docCommand}




\section{Experimental features}\CHDocNew{0.3}

\begin{marker}
The content and description of the features are marked as experimental as of version \packageversion. Features are subject to changes as well as macro names might be revised in future versions. 
\end{marker}

The tracking of counters with respect to some fixed number of a track level counter might get tedious, i.e. it is not very convenient to remember a special section number of which counter \CHDocCounter{foo} should be tracked. \CHDocPackage{\PackageDocName} provides the possibility to add a label to some track level counter and obtaining the running total number of the relevant counter by using \refCom{ObtainTrackedValueByLabel}.


\begin{docCommand}{tracklabel}{\oarg{counter name}\marg{label name}} \CHDocNew{0.3}
  \cs{tracklabel} provides a label given in the first mandatory argument to a track level counter -- the counter is being auto detected with \cs{LastRefSteppedCounter} from \CHDocPackage{xassoccnt}. 

In addition, the a label with the same name is set with the usual \cs{label} command. Use \refCom{tracklabel*} to suppress the generation of such labels. 

\begin{codeoptionsenum}
\item \oarg{counter name}: This is only used as an optional argument to the \cs{label} command as provided by \CHDocPackage{cleveref}.
\item \marg{label name}: A label for a track level counter.
\end{codeoptionsenum}

\end{docCommand}

\begin{docCommand}{tracklabel*}{\oarg{counter name}\marg{label name}} \CHDocNew{0.3}
This is the starred version of \refCom{tracklabel} but does not generate a usual label of the name given with the first mandatory argument. The optional argument is ignored as of version \packageversion. 
\end{docCommand}



\begin{marker}
Please note that the usability of \refCom{tracklabel} is restricted to track level counters that have been used with \cs{refstepcounter} as of version \packageversion!

\end{marker}


\begin{docCommand}[before={\CHDocExpCommand}]{ObtainTrackedValueByLabel}{\oarg{counter name}\marg{label name}\marg{tracked counter}} \CHDocNew{0.3}

This command uses a label given with \refCom{tracklabel} to some track level counter usage and will return the relevant number of the tracked counter. The underlying track level counter is autodetected using \CHDocPackage{zref} properties. 
\begin{codeoptionsenum}
\item \oarg{counter name}: Use this to override the auto detection of the track level counter. This might cause unpredictable logical errors, however. 
\item \marg{label name}: A label for a track level counter.
\item \marg{tracked counter}: The name of a counter being in the tracking list of the (auto detected) track level counter. 
\end{codeoptionsenum}

\begin{itemize}
\item If the given label is not defined, a \texttt{??} is printed instead. As of version \packageversion\ there is no warning or error message. 
\item This command is expandable!
\end{itemize}
\end{docCommand}

See \Cref{packageexample::tracking_by_label} for an example using the tracking - by - label - feature.



\begin{docCommand}{AddToTrackedCounters}{\marg{tracked counters}\marg{counter value}} \CHDocNew{0.3}
  This macro adds the same value to a comma separated list of tracked counters without using \cs{stepcounter}.
  \begin{codeoptionsenum}
  \item \marg{tracked counters}: A comma separated list of counter names.
  \item \marg{counter value}: An integer value
  \end{codeoptionsenum}
\end{docCommand}



\section{Examples}

\subsection[Item count of enumerate]{Count the items of an enumerate}


\tcbset{breakable}
\begin{dispListing}
\documentclass{article}

\usepackage{xcntperchap}
\usepackage{enumitem}



\RegisterCounters{section}{enumi}
\RegisterCounters{subsection}{enumi}

\begin{document}
\tableofcontents

\section{Section 1 -- with \ObtainTrackedValueExp{section}{enumi} items}
    \begin{enumerate}[resume]
        \item Item 1
        \item Item 2
        \item Item 3
    \end{enumerate}

\subsection{Another subsection with \ObtainTrackedValueExp{subsection}{enumi} }

\begin{enumerate}[resume]
\item Item 4
\item Item 5
\end{enumerate}


\section{Section 2 -- with \ObtainTrackedValueExp{section}{enumi} items}
\begin{enumerate}[resume]
\item Item 6
\item Item 7
\end{enumerate}

\subsection{Another subsection with \ObtainTrackedValueExp[2]{subsection}{enumi} Items } % Second total subsection to be used. 

\begin{enumerate}[resume]
\item Item 8
\item Item 9
\item Item 10
\item Item 11
\item Item 12
\item Item 13
\end{enumerate}

\end{document}
\end{dispListing}


\subsection[Item count of enumerate -- alternate version]{Count the items of an enumerate -- with label reference}\label{packageexample::tracking_by_label}


\tcbset{breakable}
\begin{dispListing}
\documentclass{article}

\usepackage{xcntperchap}
\usepackage{enumitem}



\RegisterCounters{section}{enumi}
\RegisterCounters{subsection}{enumi}

\begin{document}
\tableofcontents

\section{Section 1 -- with \ObtainTrackedValueExp{section}{enumi} items} \tracklabel{sectionlabel}
    \begin{enumerate}[resume]
        \item Item 1
        \item Item 2
        \item Item 3
    \end{enumerate}

\subsection{Another subsection with \ObtainTrackedValueExp{subsection}{enumi} items}

\begin{enumerate}[resume]
\item Item 4
\item Item 5
\end{enumerate}


\section{Section 2 -- with \ObtainTrackedValueExp{section}{enumi} items} 
\begin{enumerate}[resume]
\item Item 6
\item Item 7
\end{enumerate}

\subsection{Another subsection with \ObtainTrackedValueExp[2]{subsection}{enumi} Items } \tracklabel{subsec::somelabel}


However, you can use a label as well: \ObtainTrackedValueByLabel{subsec::somelabel}{enumi} Items

\begin{enumerate}[resume]
\item Item 8
\item Item 9
\item Item 10
\item Item 11
\item Item 12
\item Item 13
\end{enumerate}

\end{document}
\end{dispListing}




\clearpage

\section{To-Do list}\label{section::todo}

\begin{itemize}
\item Better error handling (no checks for many features so far).
\item More options for fine control of the behaviour package and macros.
\item Easy - adaption for other documentclasses, especially for \classname{beamer}
\item Improve documentation
\item More examples
\end{itemize}

If you 

\begin{itemize}
  \item find bugs
  \item errors in the documentation
  \item have suggestions
  \item have feature requests
\end{itemize}

don't hesitate and contact me via \makeatletter christian.hupfer@yahoo.de\makeatother

\clearpage


\section{Acknowledgments}

I would like to express my gratitudes to the developpers of fine \LaTeX{} packages and of course
to the users at tex.stackexchange.com, especially:

\begin{marker}
A special gratitude goes to Prof. Dr. Dr. Thomas Sturm for providing the wonderful \CHDocPackage{tcolorbox} package which was used to
write this documentation.
\end{marker}


\section{Version history}

\begin{itemize}[itemsep=15pt]


\item \CHDocFullVersion{0.5}
  Improved the core \cs{setcounter} in order to grab changes for relevant counters there as well.

\item \CHDocFullVersion{0.4}
  Improved the core \cs{stepcounter} in order to fit the \CHDocPackage{expl3} and \CHDocPackage{xparse} changes of Februar - April 2017. 
\item   \CHDocFullVersion{0.3}
  \begin{itemize}
  \item \CHDocNew{0.3} Support for obtaining a tracked value level by using labels with \refCom{tracklabel}, \refCom{tracklabel*} and \refCom{ObtainTrackedValueByLabel}
  \item \CHDocNew{0.3} Added the \refCom{RegisterTrackCounter} and \refCom{RegisterMultipleTrackCounters} as a replacement of \refCom{RegisterCounters}. 
  \item Added \refCom{AddToTrackedCounters} macro to circumvent counter value update problems for specific tracked counters. 
  \end{itemize}
\item 
Version \chdocextractversion{xcntperchapversion0.2} \tcbdocmarginnote{\tcbdocnew{\chdocextractversion{xcntperchapversion0.2}}}
\begin{itemize}
\item Added the expandable version of \cs{ObtainTrackedValues} 
\item Removed the bug concerning the missing reset of the associated counters
\end{itemize}

\item 
Version \chdocextractversion{xcntperchapversion0.1} \tcbdocmarginnote{\tcbdocnew{\chdocextractversion{xcntperchapversion0.1}}}

Bootstrap version, rewrite of previous \CHDocPackage{cntperchap} with LaTeX - 3 - Kernel features

\end{itemize}




\clearpage
\printindex



\end{document}