summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/xcntperchap/xcntperchap_doc.tex
blob: 3b9f12cc1a8c9f1e980c167d636c3cf116c6d48f (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
%% LaTeX package xcntperchap - version 0.2 (2016/06/07 -- 09/05/23)
%% Documentation file for xcntperchap.sty
%%
%%
%% -------------------------------------------------------------------------------------------
%% Copyright (c) 2016 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de>
%% -------------------------------------------------------------------------------------------
%%
%% 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{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}


\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}
          Author: \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}
}

\usepackage{xcntperchap}


\newcommand{\PackageDocName}{xcntperchap}%



\newcommand{\mymailtoaddress}{%
  christian.hupfer@yahoo.de
}


\def\packageversion{\xcntperchappackageversion}%

\makeindex[intoc]

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

\hypersetup{breaklinks=true}



\hypersetup{breaklinks=true,
  pdftitle={\jobname.pdf -- version \packageversion},
  pdfauthor={PACKAGEAUTHOR},
  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.

\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}, this package is also needed%

\begin{itemize}
\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}{RegisterCounters}{\marg{track counter}\marg{counter1, counter2,...}} \tcbdocmarginnote{\tcbdocnew{\chdocextractversion{xcntperchapversion0.1}}}

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}{RegisterCounters}%
  \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}%


\section{User commands}


\begin{docCommand}{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}
\clearpage

\begin{docCommand}{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 are calculations, comparisions and write - operations to files are requested.

The meaning of arguments is the same as in \refCom{ObtainTrackedValue}. 
\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}


\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 to

\begin{itemize}
  \item Paulo Roberto Massa Cereda
  \item Enrico Gregorio
  \item Joseph Wright
  \item David Carlisle
  \item Werner Grundlingh
  \item Gonzalo Medina
\end{itemize}

for their invaluable help on many questions on macros.

\vspace{2\baselineskip}
\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}
\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}