summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-08-14 22:03:52 +0000
committerKarl Berry <karl@freefriends.org>2014-08-14 22:03:52 +0000
commit3cff191286e3cb279c738c8a68cec641bb61effd (patch)
tree0bda4daf5266ba412a200313641dde191df3f40d /Master/texmf-dist
parent4a8be113ce277ee7326c01599b3b4fac3c677e87 (diff)
assoccnt (14aug14)
git-svn-id: svn://tug.org/texlive/trunk@34934 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r--Master/texmf-dist/doc/latex/assoccnt/README39
-rw-r--r--Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.pdfbin0 -> 97388 bytes
-rw-r--r--Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.tex97
-rw-r--r--Master/texmf-dist/doc/latex/assoccnt/assoccntdoc.pdfbin0 -> 171849 bytes
-rw-r--r--Master/texmf-dist/doc/latex/assoccnt/assoccntdoc.tex277
-rw-r--r--Master/texmf-dist/tex/latex/assoccnt/assoccnt.sty171
6 files changed, 584 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/assoccnt/README b/Master/texmf-dist/doc/latex/assoccnt/README
new file mode 100644
index 00000000000..dc2c1117648
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/assoccnt/README
@@ -0,0 +1,39 @@
+%% LaTeX package assoccnt - version 0.2 (2014/08/13)
+%%
+%% -------------------------------------------------------------------------------------------
+%% Copyright (c) 2014 by Dr. Christian Hupfer <christian dot hupfer at siebenfelsen 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'.
+%%
+%% This work consists of all files listed in README
+%%
+
+The package assoccnt provides a way of associating counters to an
+existing driver counter, such incrementing the driver counter will increase
+the associated counters as well. This package can be regarded as a supplement
+to the totcount package by Vasileios Koutavas (http://www.ctan.org/pkg/totcount), but
+can be used without it too.
+
+Further improvements will follow
+
+Directory listing:
+
+ assoccntdoc.pdf 171849 08/13/14 18:50:12
+ assoccntdoc.tex 9313 08/13/14 18:50:09
+assoccnt_example.pdf 97388 08/11/14 16:15:40
+assoccnt_example.tex 2687 08/11/14 14:01:03
+ assoccnt.sty 4907 08/13/14 22:58:31
+
+Installation:
+
+Unpack assoccnt.zip to your local Tex distribution tree.
+
diff --git a/Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.pdf b/Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.pdf
new file mode 100644
index 00000000000..af901043e68
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.tex b/Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.tex
new file mode 100644
index 00000000000..af6e1ddd295
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.tex
@@ -0,0 +1,97 @@
+\documentclass{book}%
+
+\usepackage{totcount}%
+\usepackage{assoccnt}%
+
+% Some packages only for output and dummy pages
+\usepackage{blindtext}%
+\usepackage{forloop}%
+\usepackage{xcolor}%
+
+\newcounter{loopcounter}%
+
+\newcommand{\ShowNiceCounterOutput}[5]{%
+\begin{center}%
+\begin{tabular}{llll}%
+& & & \tabularnewline
+& \multicolumn{3}{c}{totcount page values} \tabularnewline
+Page & \textcolor{red}{#1} & \textcolor{blue}{#2} & \textcolor{gray}{#3} \tabularnewline
+\thepage & \textcolor{red}{\number\totvalue{#1}} & \textcolor{blue}{\number\totvalue{#2}} & \textcolor{gray}{\number\totvalue{#3}} \tabularnewline
+& & & \tabularnewline
+ & \multicolumn{3}{c}{totcount section values} \tabularnewline
+Section & \textcolor{red}{#4} & \textcolor{blue}{#5} \tabularnewline
+\thesection & \textcolor{red}{\number\totvalue{#4}} & \textcolor{blue}{\number\totvalue{#5}} & \tabularnewline
+& & & \tabularnewline
+\end{tabular}
+\end{center}%
+}%
+
+
+\newcommand{\QuickOutput}[1]{%
+%
+\forloop{loopcounter}{1}{\value{loopcounter} < \numexpr #1+1}{%
+\pagenumbering{arabic}% -> pagenumber reset to zero , on purpose inside the loop
+\ShowNiceCounterOutput{page}{totalpages}{anotherpagescounter}{section}{totalsections}%
+\blindtext%
+\newpage% some pages
+}%
+}%
+
+
+
+\begin{document}
+\regtotcounter{page} % Register a total value counter --> this will be the driver counter
+\newtotcounter{totalpages}% 1st driven counter
+\newtotcounter{anotherpagescounter}% 2nd driven counter
+\newtotcounter{yetanotherpagescounter}% 3rd driven counter
+
+
+\regtotcounter{section}%
+\newtotcounter{totalsections}
+
+\DeclareAssociatedCounters{page}{totalpages,anotherpagescounter}% Register the driver and the driven counters
+\DeclareAssociatedCounters{section}{section,totalsections}% Register the driver and the driven counters for sections%
+\DeclareAssociatedCounters{page}{yetanotherpagescounter}% Register the driver and the driven counters
+
+
+
+\pagenumbering{Roman}%
+
+\chapter{The first chapter}%
+
+\section{My first section}%
+
+% Generate dummy output
+\QuickOutput{10}%
+
+
+\section{My second section}%
+
+\QuickOutput{10}%
+
+\pagenumbering{arabic}% -> pagenumber reset to zero
+
+\appendix
+
+\chapter{First Appendix chapter}%
+
+\section{My (only) appendix section}%
+
+
+% Generate dummy output, again ;-)
+\QuickOutput{10}%
+
+% Clear the list of counters associated to page
+\ClearAssociatedCountersList{page}%
+
+% Not necessary, only for removing some counters from list
+\RemoveAssociatedCounters{page}{totalpages,anotherpagescounter}%
+% Readd the counter totalpages to the list --> in this context,
+% It acts, as if it has not been removed at all
+\DeclareAssociatedCounters{page}{totalpages}
+
+\QuickOutput{20}%
+
+
+
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/assoccnt/assoccntdoc.pdf b/Master/texmf-dist/doc/latex/assoccnt/assoccntdoc.pdf
new file mode 100644
index 00000000000..ce125147dcc
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/assoccnt/assoccntdoc.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/assoccnt/assoccntdoc.tex b/Master/texmf-dist/doc/latex/assoccnt/assoccntdoc.tex
new file mode 100644
index 00000000000..d0a78675538
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/assoccnt/assoccntdoc.tex
@@ -0,0 +1,277 @@
+\documentclass[12pt,paper=a4]{ltxdoc}
+
+\usepackage[lmargin=2cm,rmargin=2cm]{geometry}
+\usepackage{totcount}%
+\usepackage{assoccnt}%
+\usepackage{blindtext}%
+\usepackage{xcolor}
+\usepackage{imakeidx}%
+\usepackage{tcolorbox}
+\usepackage{datetime}%
+\usepackage{scrpage2}%
+\tcbuselibrary{listings}%
+\tcbuselibrary{documentation}%
+
+\usepackage{array}%
+\usepackage{amsmath}%
+\usepackage{amsthm}%
+
+
+\newcommand{\MarkupPackageName}[2][lightgray]{%
+\colorbox{#1}{\textcolor{black}{#2}}%
+}%
+
+\newcommand{\MarkupMacroName}[2][cyan]{%
+\colorbox{#1}{\(\backslash\)\textcolor{black}{#2}}%
+}%
+
+\newcommand{\MarkupCounterName}[2][yellow]{%
+\colorbox{#1}{\textcolor{black}{\texttt{#2}}}%
+}%
+
+\def\packageversion{0.2}%
+
+\makeindex
+
+\newcommand{\PackageDocName}{assoccnt.sty}%
+
+\begin{document}
+\mmddyyyydate
+
+
+\setlength{\parindent}{0pt}
+\newtotcounter{totalpages}%
+\newtotcounter{anothertotalpages}%
+
+\newtotcounter{totalproofs}%
+\newtotcounter{totalsections}%
+
+\DeclareAssociatedCounters{section}{totalsections}%
+\DeclareAssociatedCounters{proof}{totalproofs}
+
+
+\DeclareAssociatedCounters{page}{anothertotalpages,totalpages}
+
+\thispagestyle{empty}%
+
+\begin{center}
+\begin{tcolorbox}[colback=yellow!30!white,width=0.8\textwidth]
+\large \bfseries%
+\begin{center}%
+\begin{tabular}{c}%
+\textsc{\PackageDocName} \tabularnewline
+\tabularnewline
+Associate counters stepping simultaneously \tabularnewline
+\tabularnewline
+Version \packageversion \tabularnewline
+\tabularnewline
+\today \tabularnewline
+\tabularnewline
+Author: Christian Hupfer\footnote{\makeatletter christian.hupfer@siebenfelsen.de}
+\tabularnewline
+\end{tabular}
+\end{center}
+
+\end{tcolorbox}
+
+
+\end{center}
+
+\tableofcontents
+\clearpage
+
+
+
+\pagestyle{scrheadings}%
+\setheadsepline{2pt}[\color{blue}]
+
+
+\section{Introduction}
+
+The aim of this package is to provide some additional support for example for a package like \MarkupPackageName{totcount}.
+
+For example, the total number of pages in a document could be achieved by using
+
+\begin{dispExample}%
+\regtotcounter{page}
+...
+The number of pages in the document is \number\totvalue{page} page(s).
+\end{dispExample}%
+
+This will work, as long there is no reset of the page counter, as it might happen in the case of \cs{setcounter} or \cs{pagenumbering} being applied in the document. The result is a false page counter total value.
+
+This package provides associate counters, i.e. counters that are increased simultaneously with a driver counter and are not influenced by a a resetting of the driver counter, as long as not being added to the reset list by definition of the counter or explicitly by \cs{@addtoreset}.
+
+This package defines some macros to handle associated counters. The only interception to the standard behaviour is within the redefined commands \cs{stepcounter} and \cs{refstepcounter}. The usual commands still work, as there is code added to their definition.
+
+Internally, the associated counters are stored in one list per counter -- it is not recommended to operate on those lists directly.
+
+
+
+\section{Documentation of Macros}
+\tcbset{color command={blue}}
+All macros have the general rule, that the driver counter is specified as 1st argument to the macro.
+
+\begin{docCommand}{DeclareAssociatedCounters}{\marg{driver counter}\marg{associated counters list}}
+This command is the main macro of the package. It declares the counter names being specified in comma - separated - list (CSV) which should be stepped simultaneously when the driver counter is increased by \cs{stepcounter}.
+
+
+Note, that this command should be used as early as possible, i.e. in the preamble of the document, since the driven counters are not increased as long as they are not associated to the driver counter. On the hand, it is possible, to control the starting point of the association at any position in the body of the document, when the association should start later on.
+
+\begin{dispExample}
+%%%% The association of anothertotalpages in this example just takes place here, so the stepping of the counter will start from here and providing a 'wrong' value.
+%%%%
+\DeclareAssociatedCounters{page}{totalpages,anothertotalpages}
+This document has \number\totvalue{totalpages} (note: \number\totvalue{anothertotalpages}) pages.
+\end{dispExample}
+
+
+
+\begin{itemize}
+ \item Current version state:
+ \begin{itemize}
+ \item No checking whether the 1st and 2nd arguments hold counter names is applied.
+ \item No check is done whether two (or more) associated counters are mutually associated.
+ \end{itemize}
+ \item A self-association of the driver counter to itself is ignored internally as this would lead to inconsistent counter values.
+ \item The order of the specification of associated counters in the 2nd arguments is of no importance.
+ \item Specifing an associated counter name multiple times has no effect, only the first occurence of the name will be used.
+\end{itemize}
+
+\end{docCommand}
+
+
+\begin{docCommand}{RemoveAssociatedCounter}{\marg{driver counter}\marg{associated counter}}
+This command removes a counter from the existing list for a driver counter, i.e. the counter will not be increased any longer by \cs{stepcounter}. It can be increased however manually, of course.
+\end{docCommand}
+
+\begin{dispExample}
+\RemoveAssociatedCounter{page}{anothertotalpages}
+This document has \number\totvalue{totalpages} (beware: \number\totvalue{anothertotalpages}) pages.
+\end{dispExample}
+
+
+
+\begin{docCommand}{RemoveAssociatedCounters}{\marg{driver counter}\marg{list of associated counters}}
+This command removes the comma-separated-value list of counters from the existing list for a driver counter, i.e. the counters will not be increased any longer by \cs{stepcounter}. They can be increased however manually, of course.
+
+Take care not to confuse the commands \refCom{RemoveAssociatedCounters}
+and{}\linebreak \refCom{RemoveAssociatedCounter}
+\end{docCommand}
+
+\begin{docCommand}{ClearAssociatedCounters}{\marg{driver counter}}
+This command clears the internal list for all counters associated to the \marg{driver counter}. The counters will not be increased automatically.
+\end{docCommand}
+
+\begin{docCommand}{IfIsAssociatedCounter}{\marg{driver counter}\marg{associated counter}\marg{True branch}\marg{False branch}}
+This macro checks, whether a counter is associated to the driver counter and expands the corresponding branch. If the internal driver counter list does not exist, the false branch will be used, since this also means, that the possibly associated counter is not associated at all.
+
+\begin{dispExample}
+% Remove associated counter first for demonstration purposes
+\RemoveAssociatedCounter{page}{anothertotalpages}
+\IfIsAssociatedCounter{page}{totalpages}{Yes, totalpages is associated}{No, totalpages is not associated}
+
+\IfIsAssociatedCounter{page}{anothertotalpages}{Yes, anothertotalpages is associated}{No, anotherpages is not associated}
+\end{dispExample}
+\end{docCommand}
+
+\clearpage
+
+
+\section{To do list}
+
+\begin{itemize}
+\item Check the existence of driver and associated counters
+\item Improve documentation
+\end{itemize}
+
+\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 Enrico Gregorio
+ \item Joseph Wright
+ \item David Carlisle
+ \item Werner
+\end{itemize}
+
+for their invaluable help on many questions on macros.
+
+\vspace{2\baselineskip}
+A special gratitude goes to Prof. Dr. Dr. Thomas Sturm for providing the wonderful \MarkupPackageName{tcolorbox} package which was used to
+write this documentation.
+
+\clearpage
+
+\appendix
+\section{Example: Total number of sections}
+In this example, all sections of this document are counted, i.e. the current one as well as all following ones.
+\begin{dispExample}
+\DeclareAssociatedCounters{section}{totalsections}%
+This document has \number\totvalue{totalsections} section(s)%
+\end{dispExample}
+
+
+\section{Example: Total number of subsections with suspension}
+
+In this example, the subsections of this document are counted but later on, the associatedcounter is removed from the list, so it is frozen.
+
+\begin{dispExample}
+\newtotcounter{totalsubsections}%
+\DeclareAssociatedCounters{subsection}{totalsubsections}%
+
+\subsection{First dummy subsection}
+SubSection counter: \thesubsection~-- \number\totvalue{totalsubsections}
+\subsection{Second dummy subsection}
+SubSection counter: \thesubsection~-- \number\totvalue{totalsubsections}
+
+\RemoveAssociatedCounter{subsection}{totalsubsections}
+
+\subsection{Third dummy subsection after removing the associated counter}
+SubSection counter: \thesubsection~-- \number\totvalue{totalsubsections}
+\end{dispExample}
+
+
+
+\section{Example: Total number of proofs}
+
+
+\begin{dispExample}
+% \usepackage{amsthm} is needed
+\newcounter{proof}%
+\newtheorem{Proof}[proof]{Proof}%
+\DeclareAssociatedCounters{proof}{totalproofs}
+\begin{Proof}
+It's trivial.
+\end{Proof}
+
+\begin{Proof}[On Brontosaurs]
+See excavations!
+\end{Proof}
+
+%%% Manipulate the counter
+\setcounter{proof}{17}
+
+\begin{Proof}[Yet another proof]
+\begin{align*}
+ E &= m c^2
+ \end{align*}
+\end{Proof}
+
+This document has \number\totvalue{totalproofs} proofs %
+
+\end{dispExample}
+
+\clearpage
+
+%%%% Index of commands
+
+\printindex
+
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/assoccnt/assoccnt.sty b/Master/texmf-dist/tex/latex/assoccnt/assoccnt.sty
new file mode 100644
index 00000000000..b6406ff56a4
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/assoccnt/assoccnt.sty
@@ -0,0 +1,171 @@
+\NeedsTeXFormat{LaTeX2e}%
+\ProvidesPackage{assoccnt}[2014/08/13 v0.2 -- Associate counters stepping]%
+%%%
+%% License: LaTeX Project Public License
+%% Copyright (2014) Dr. Christian Hupfer
+%% Author: Christian Hupfer christian.hupfer@siebenfelsen.de
+%%
+%%
+%%%%
+%%% Some options later on
+%%%%
+
+\RequirePackage{etoolbox}[2011/01/03 2.2]%
+
+
+
+\let\@@assoccnt@standardstepcounter\stepcounter%
+
+\let\@@assoccnt@standardrefstepcounter\refstepcounter%
+
+
+% Just for a quick suffix
+\newcommand{\@@associatedcounterslistsuffix}{%
+AssociatedCountersList%
+}%
+
+
+
+%%% Internal macro to generate the name of the list of associated counters
+\newcommand{\@@assoccnt@@generatelistname}[1]{%
+% #1 Name of the driver counter
+@#1\@@associatedcounterslistsuffix
+}%
+
+
+\newcommand{\@@assoccnt@@addassociatedcounter}[2]{%
+ \ifcsdef{#1}{%
+ \ifinlistcs{#2}{#1}{%
+ % Do nothing, since counter is already in the list
+ }{%
+ \listcsadd{#1}{#2}%
+ }%
+ }{%
+ % Nothing in here
+ }%
+}%
+
+
+
+
+% This command defines a list of counters, that should be stepped also if the driver counter
+% is `\stepcounter`ed.
+% A self - association is not possible, as this would lead to inconsistent counting
+\newcommand{\DeclareAssociatedCounters}[2]{%
+% #1 --> driver counter
+% #2 --> CSV list of other counters, that should be stepped, if the driver counter is stepped
+ \ifcsdef{\@@assoccnt@@generatelistname{#1}}{%
+ % % Nothing to be done --> List already exists
+ \GenericWarning{}{Warning: List of associated counters for counter #1 already exists}%
+ }{%
+ \csgdef{\@@assoccnt@@generatelistname{#1}}{}% Define some global list
+ }%
+ % Now add the counter names from #2 to the list
+ % Note: Currently, it is not checked whether a counter is already added!
+ \forcsvlist{\@@assoccnt@@addassociatedcounter{\@@assoccnt@@generatelistname{#1}}}{#2}%
+ % Now remove an accidental self-association
+ \RemoveAssociatedCounter{#1}{#1}%
+}%
+
+
+
+%%% A generic macro, that removes a list entry from the list by
+%%% defining a temporary list and omitting the
+\newcommand{\@@assoccnt@removefromlist}[2]{%
+% #1 list name
+% #2 element to be removed
+ \ifcsdef{#1}{%
+ \gdef\@@mytemplist{}%
+ \renewcommand*{\do}[1]{%
+ \ifstrequal{##1}{#2}{
+ % Later one some success routine etc. ???
+ }{%
+ \listgadd{\@@mytemplist}{##1}%
+ }%
+ }%
+ \dolistcsloop{#1}%
+ \csxdef{#1}{\@@mytemplist}%
+ }{%
+ % The list is not defined at all, can't remove something from something not existing...
+ }%
+}%
+
+
+
+%% Remove a particular counter from the list
+\newcommand{\RemoveAssociatedCounter}[2]{%
+% #1 arg: driver counter
+% #2 arg: counter name to be removed
+ \@@assoccnt@removefromlist{\@@assoccnt@@generatelistname{#1}}{#2}%
+}%
+
+%% Remove a CSV list of counters from the list of associated counters
+
+\newcommand{\RemoveAssociatedCounters}[2]{%
+% #1 arg: driver counter
+% #2 arg: CSV list of counters to be removed
+ \forcsvlist{\RemoveAssociatedCounter{#1}}{#2}%
+}%
+
+%% Remove all associated counters from the list
+\newcommand{\ClearAssociatedCountersList}[1]{%
+% #1 arg: driver counter
+ \csundef{\@@assoccnt@@generatelistname{#1}}%
+}%
+
+
+%% Test if a counter is an associated counter of driver counter
+\newcommand{\IfIsAssociatedCounter}[4]{%
+% #1 arg: driver counter
+% #2 arg: (possibly) associated counter
+% #3 arg: Code for execution on true branch
+% #4 arg: Code for execution on false branch
+ \ifcsdef{\@@assoccnt@@generatelistname{#1}}{%
+ \ifinlistcs{#2}{\@@assoccnt@@generatelistname{#1}}{%
+ #3%
+ }{%
+ #4%
+ }%
+ }{% List does not exist, so it's not associated
+ #4%
+ }%
+}%
+
+
+%%% The stepcounter wrapper for the standard stepcounter command
+%%% This is just for convenience, if the command as to be improved/extended later on in future
+\newcommand{\@@assoccnt@stepcounter}[1]{%
+ \@@assoccnt@standardstepcounter{#1}%
+}%
+
+%%% Not needed so far
+\newcommand{\@@assoccnt@refstepcounter}[1]{%
+ \@@assoccnt@standardrefstepcounter{#1}%
+}%
+
+%%%% Redefinition of the \stepcounter command
+\renewcommand{\stepcounter}[1]{%
+ \@@assoccnt@standardstepcounter{#1}% Traditional behaviour, since this is expected!
+ \ifcsdef{\@@assoccnt@@generatelistname{#1}}{% Check first, whether the list exists at all,
+ \forlistcsloop{\@@assoccnt@stepcounter}{\@@assoccnt@@generatelistname{#1}}% March through the list
+ }{%
+ %No list -> do nothing at all
+ }%
+}%
+
+
+
+%%%% Redefinition of the \stepcounter command
+\renewcommand{\refstepcounter}[1]{%
+ \@@assoccnt@standardstepcounter{#1}% Traditional behaviour, since this is expected!
+ \protected@edef\@currentlabel%
+ {\csname p@#1\endcsname\csname the#1\endcsname}%
+ \ifcsdef{\@@assoccnt@@generatelistname{#1}}{% Check first, whether the list exists at all,
+ \forlistcsloop{\@@assoccnt@stepcounter}{\@@assoccnt@@generatelistname{#1}}% March through the list
+ }{%
+ %No list -> do nothing at all
+ }%
+}%
+
+
+\endinput% \ No newline at end of file