diff options
author | Karl Berry <karl@freefriends.org> | 2014-09-04 21:10:23 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-09-04 21:10:23 +0000 |
commit | 23550e4b6a7407977d39f6339f6f9fe2db2ba99e (patch) | |
tree | d617006b38f0e36523c53b14219500d24f8ef939 | |
parent | 44619feacee76d2abea54c66454f19077701adbc (diff) |
assoccnt (4sep14)
git-svn-id: svn://tug.org/texlive/trunk@35106 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/assoccnt/README | 26 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.pdf | bin | 49574 -> 77420 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.tex | 108 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/assoccnt/assoccntdoc.pdf | bin | 198651 -> 254717 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/assoccnt/assoccntdoc.tex | 288 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/assoccnt/assoccnt.sty | 274 |
6 files changed, 609 insertions, 87 deletions
diff --git a/Master/texmf-dist/doc/latex/assoccnt/README b/Master/texmf-dist/doc/latex/assoccnt/README index 28aa89f3723..a3211634d6f 100644 --- a/Master/texmf-dist/doc/latex/assoccnt/README +++ b/Master/texmf-dist/doc/latex/assoccnt/README @@ -1,7 +1,7 @@ -%% LaTeX package assoccnt - version 0.3 (2014/08/21) +%% LaTeX package assoccnt - version 0.4 (2014/09/04) %% %% ------------------------------------------------------------------------------------------- -%% Copyright (c) 2014 by Dr. Christian Hupfer <christian dot hupfer at siebenfelsen dot de> +%% Copyright (c) 2014 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de> %% ------------------------------------------------------------------------------------------- %% %% This work may be distributed and/or modified under the @@ -25,13 +25,21 @@ can be used without it too. Further improvements will follow -This version provides some new routines for queries on the properties of counters -whether they are drivers or associated counters and a better documentation. + +This version provides + +-- a revised scheme -- \addtocounter is used instead of \stepcounter +-- \setcounter is redefined to obtain an optional argument, which holds + a list of associated counters, which should be set to the value as well. +-- Suspension/resuming of counter is possible, i.e. the counting can be put on hold + and resumed later on. +-- some new routines for queries on the properties of counters + whether they are drivers or associated counters and a better documentation. Directory listing: - assoccntdoc.pdf 198651 08/21/14 18:33:30 - assoccntdoc.tex 20011 08/21/14 18:33:30 -assoccnt_example.pdf 49574 08/21/14 18:33:30 -assoccnt_example.tex 2681 08/21/14 18:33:25 - assoccnt.sty 8774 08/21/14 18:33:25 + assoccntdoc.pdf 254717 09/04/14 03:19:44 + assoccntdoc.tex 29162 09/04/14 03:19:45 +assoccnt_example.pdf 77420 09/04/14 03:19:45 +assoccnt_example.tex 3955 09/04/14 03:15:58 + assoccnt.sty 14299 09/04/14 03:15:58 diff --git a/Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.pdf b/Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.pdf Binary files differindex 1ba1f89e91e..63fe2a67cbe 100644 --- a/Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.pdf +++ b/Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.pdf diff --git a/Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.tex b/Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.tex index 8d58612b262..462ed9f7d08 100644 --- a/Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.tex +++ b/Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.tex @@ -23,20 +23,25 @@ + \newcounter{loopcounter}% -\newcommand{\ShowNiceCounterOutput}[5]{% +\newcommand{\QuickSections}[2]{% +\forloop{loopcounter}{1}{\value{loopcounter} < \numexpr #1+1}{% +\csuse{#2}{Dummy #2 -- \theloopcounter} +}% +}% + +\newcommand{\ShowNiceCounterOutput}[6]{% \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\value{#2}} & \textcolor{gray}{\number\value{#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 +\begin{tabular}{lllll}% +& & & & \tabularnewline +& \multicolumn{4}{c}{totcount page values} \tabularnewline +Page & \textcolor{red}{#1} & \textcolor{blue}{#2} & \textcolor{gray}{#3} & \textcolor{violet}{#4}\tabularnewline +\thepage & \textcolor{red}{\number\totvalue{#1}} & \textcolor{blue}{\number\value{#2}} & \textcolor{gray}{\number\value{#3}} & \textcolor{violet}{\number\totvalue{#4}} \tabularnewline +Section & \textcolor{red}{#5} & Subsection & \textcolor{blue}{#6} & \tabularnewline% +\thesection & \textcolor{red}{\number\totvalue{#5}} & \thesubsection & \textcolor{blue}{\number\totvalue{#6}} & \tabularnewline +& & & & \tabularnewline \end{tabular} \end{center}% }% @@ -46,62 +51,111 @@ Page & \textcolor{red}{#1} & \textcolor{blue}{#2} & \textcolor{gray}{#3} \tabula % \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}% +\ShowNiceCounterOutput{page}{associatedpages}{anotherpagescounter}{yetanotherpagescounter}{associatedsections}{associatedsubsections}% \blindtext% \newpage% some pages }% }% -\newcounter{totalpages} -\newtotcounter{totalsections}% + + +\newcounter{associatedpages}% \newcounter{anotherpagescounter}% \regtotcounter{page} % Register a total value counter --> this will be the driver counter \newtotcounter{yetanotherpagescounter}% 3rd driven counter +\newtotcounter{associatedsections}% + +\newtotcounter{associatedsubsections}% -\DeclareAssociatedCounters{page}{totalpages,anotherpagescounter,totalpages}% Register the driver and the driven counters -\DeclareAssociatedCounters{totalpages}{anotherpagescounter}% Register the driver and the driven counters -\DeclareAssociatedCounters{section}{totalsections}% +\DeclareAssociatedCounters{page}{associatedpages,anotherpagescounter,associatedpages,yetanotherpagescounter}% Register the driver and the driven counters +\DeclareAssociatedCounters{section}{associatedsections}% +\DeclareAssociatedCounters{subsection}{associatedsubsections}% + \begin{document} \tableofcontents% +\chapter*{Introduction} + +This is a dummy document -- it just shows how some of the commands work. +In section \ref{section::query} same queries and statistics are shown. \chapter{Chapter one} \section{First} +\QuickSections{10}{subsection}% + + +\QuickOutput{10} +% Suspend the associatedsubsections counters% +\typeout{Hello!} +\SuspendCounters{associatedsubsections,associatedpages}% \QuickOutput{10} +\clearpage + +\subsection[Suspended counters checking]{Checking for suspended counters} + +\IsSuspendedCounter{associatedsubsections}{Yes, Counter associatedsubsections is suspended}{No!} + +\IsSuspendedCounter{yetanothertotalpages}{Yes}{No!} -\section{Query routines}% +\clearpage + +\section{Dummy section}% + +\QuickSections{10}{subsection}% + +% Resume all counters +\ResumeSuspendedCounters +\QuickSections{20}{subsection}% + + + +\clearpage + +\section{Query routines} \label{section::query}% +\setlength{\parindent}{0pt}% \IsAssociatedCounter{totalsections}{Yes, it's associated}{Nope, it's not associated} \IsAssociatedCounter{anotherpagescounter}{Yes, it's associated}{Nope, it's not associated} -\AssociationStatistics% +\hrule\par + +Setting counter section explicitly to another value: + +\setcounter{section}{12}% + +\hrule\par + +Setting counter section explicitly to another value with option enabled: + +\setcounter[AssociatedCounters={associatedpages,anotherpagescounter,gandalf}]{page}{20}% + + + +\AssociatedDriverCounterInfo{page}% -\IsDriverCounter{section}{Yes, it's a driver counter}{No, it does not have this feature}% +\AssociatedDriverCounterInfo{associatedpages}% -\ClearAssociatedCountersList{section} +\AssociatedDriverCounterInfo{section}% -\IsDriverCounter{section}{Yes, it's a driver counter}{No, it does not have this feature}% +\AddAssociatedCounters{page}{associatedpages}% +\AddAssociatedCounters{page}{associatedpages}% -\AssociationStatistics% -Clearing the counters: +Clearing the counters (This will report wrong values for the associated counters!!!) -\ClearDriverCountersList -Show Statistics% -\AssociationStatistics% \end{document} diff --git a/Master/texmf-dist/doc/latex/assoccnt/assoccntdoc.pdf b/Master/texmf-dist/doc/latex/assoccnt/assoccntdoc.pdf Binary files differindex 292b4b322a9..d820aa2d4fd 100644 --- a/Master/texmf-dist/doc/latex/assoccnt/assoccntdoc.pdf +++ b/Master/texmf-dist/doc/latex/assoccnt/assoccntdoc.pdf diff --git a/Master/texmf-dist/doc/latex/assoccnt/assoccntdoc.tex b/Master/texmf-dist/doc/latex/assoccnt/assoccntdoc.tex index 7d848fd1088..6688576aaaa 100644 --- a/Master/texmf-dist/doc/latex/assoccnt/assoccntdoc.tex +++ b/Master/texmf-dist/doc/latex/assoccnt/assoccntdoc.tex @@ -23,7 +23,7 @@ \usepackage{amsthm}% \usepackage{totcount}% -\usepackage{assoccnt}% +\usepackage[globalsuspend=false]{assoccnt}% \usepackage{bookmark}% @@ -37,10 +37,13 @@ }% +\let\DeclareAssociatedCountersOrig\DeclareAssociatedCounters + + \newtcolorbox{docCommandArgs}[1]{colbacktitle={blue},coltitle={white},title={Description of arguments of command \cs{#1}}} -\def\packageversion{0.3}% +\def\packageversion{0.4}% \makeindex @@ -100,6 +103,7 @@ Author: Christian Hupfer\(^\mathrm{\fnsymbol{footnote}}\)% }{\makeatletter chris + \pagestyle{scrheadings}% \setheadsepline{2pt}[\color{blue}] @@ -122,17 +126,62 @@ This will work, as long there is no reset of the page counter, as it might happe 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. +This package defines some macros to handle associated counters. The only interception to the standard behaviour is within the redefined commands \cs{addtocounter} and \cs{setcounter}. The usual commands still work, as there is code added to their definition. In a previous version, \cs{stepcounter} and \cs{refstepcounter} were redefined, but since these use \cs{addtocounter} effectively, it was decided to use the basic command. Internally, the associated counters are stored in one list per counter -- it is not recommended to operate on those lists directly. +Please note, that this package does not provide means for simultaneous stepping of counters defined by plain \TeX{} \cs{newcount} command. + +\section{Package options}% + +As of version \packageversion~ the package has only one option, regarding the suspending of counters globally, regardless, whether they are drivers or associated counters (more on this facility of the package, see \ref{section::suspendedresumedcounters}. + +\begin{docKey}{globalsuspend}{=\meta{true/false}}{initially false} + If this key is set to \meta{true}, a a general driver can be set to the suspended list, i.e, it is not updated via \cs{addtocounter}. If unsure, do not use this option or say explicitly + + \begin{dispListing} + \usepackage[globalsuspend=false]{assoccnt} + \end{dispListing}% +\end{docKey} \section{Documentation of Macros} \tcbset{color command={blue}} + +\subsection{Redefined standard commands} + +\begin{docCommand}{setcounter}{\oarg{options}\marg{counter}\marg{counter value}} + +This command behaves like the standard macro \cs{setcounter}, but has an additional optional 1st argument. This optional argument can be used to enable the setting of the driver counter value as well as the associated counter values at once. + +\begin{docCommandArgs}{setcounter}% + + +\begin{enumerate}[label={\textcolor{blue}{\#\arabic*}}] + \item \oarg{options}: As of version \packageversion, the only option is the key value argument + + \begin{docKey}{AssociatedToo}{=\meta{true/false}}{initially false} + If enabled (\meta{true}), \cs{setcounter} will use the counter value for \underline{all} counters associated to this driver counter as well. Initially, this option is set to \meta{false}. + \end{docKey} + + \begin{docKey}{AssociatedCounters}{=\meta{csv list of counters}}{initially unset} + If the comma separated list of counter is set, \cs{setcounter} increases those counters only, that are driven counters of the 2nd argument, any unknown counter in this list will generate a warning and is ignored otherwise. + \end{docKey} + The option keys \refKey{AssociatedToo} and \refKey{AssociatedCounters} are mutually exclusive! + + \item \marg{counter} + + Holds the name of the counter to be set. +\item \marg{counter value} + Holds the value to be set +\end{enumerate} +\end{docCommandArgs} + +\end{docCommand}% + All macros have the general rule, that the driver counter is specified as 1st argument to the macro. \subsection{Associated counters commands} @@ -162,7 +211,6 @@ This command is the main macro of the package. It declares the counter names bei % Relax for documentation purposes -\let\DeclareAssociatedCountersOrig\DeclareAssociatedCounters \renewcommand{\DeclareAssociatedCounters}[3][]{\relax}% \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. @@ -213,6 +261,8 @@ This command adds some counters to the associated counter list for a specific dr 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. @@ -311,6 +361,7 @@ See also \item \refCom{IsAssociatedCounter} for checking whether a counter is associated \item \refCom{IsDriverCounter} in order to check whether a counter is a driver. \item \refCom{GetDriverCounter} returns the driver counter name for a given associated counter name + \item \refCom{AssociatedDriverCounterInfo} prints verbose information to the document (not to the screen!) \end{itemize} @@ -398,6 +449,174 @@ This commands tests, whether a given counter name is a driver counter and expand \end{docCommand}% +\begin{docCommand}{IsSuspendedCounter}{\marg{counter name}\marg{true branch}\marg{false branch}} +See \nameref{section::suspendedresumedcounters} on this topic. + +This command checks, whether a counter is suspended, i.e. not updated at all and expands the corresponding branches. + +\begin{docCommandArgs}{IfSuspendedCounter}% + +\begin{enumerate}[label={\textcolor{blue}{\#\arabic*}}] +\item \marg{counter name}% + + Contains the name of counter presumed to be suspended + +\item \marg{True branch} + + This code is expanded if the counter is suspended, otherwise it is ignored + +\item \marg{True branch} + + This code is expanded if the counter is \textbf{not} suspended, otherwise it is ignored + +\end{enumerate} +\end{docCommandArgs} + + + +\end{docCommand} + + +\begin{docCommand}{AssociatedDriverCounterInfo}{\marg{counter name}} + +This command is purposed for statistics only, for package/class authors for example and should not be used in a real document, as it generates verbose output to the document. + + + +\begin{dispExample} +%% Adding the counter anothertotalpages first +\AddAssociatedCounters{page}{anothertotalpages}% +\AssociatedDriverCounterInfo{page}% +\end{dispExample} + +\begin{dispExample} +% This shows information on an associated counter +\AssociatedDriverCounterInfo{totalpages}% +\end{dispExample} + +\begin{dispExample} +% This shows information on a counter which is neither a driver nor an associated counter +\AssociatedDriverCounterInfo{equation}% +\end{dispExample} + + +\end{docCommand}% + +\subsection{Minor macros} + +For the informational output on counter properties in conjunction with the macro + \refCom{AssociatedDriverCounterInfo}, some helper macros have been defined: + +\begin{docCommand}{PrettyPrintCounterName}{\oarg{countertype}\marg{counter name}} +This command just prints a counter name with frame. It's meant of informational use only. +\begin{docCommandArgs}{PrettyPrintCounterName} +\begin{enumerate}[label={\textcolor{blue}{\#\arabic*}}] +\item \oarg{options}% + + As of version \packageversion, the only option is a key value: + \begin{docKey}{countertype}{=\meta{general,driver,associated}}{general} + Use + \begin{itemize} + \item \meta{general} for an arbitrary counter name + \item \meta{driver} for a driver counter + \item \meta{associated} for an associated counter + \end{itemize} + \end{docKey} + +\item \marg{counter name} + Contains the name of counters to be displayed + +\end{enumerate} +\end{docCommandArgs}% + +Please note, that as of version \packageversion, this command does not autodetect the property of the counter nor if the 2nd argument holds a real counter name at all +\end{docCommand}% + +\begin{docCommand}{GeneralCounterInfoColor}{} +This macro holds the text color for a general counter, it defaults to \meta{\textcolor{\GeneralCounterInfoColor}{\expandafter{\GeneralCounterInfoColor}}}% +\end{docCommand} + + +\begin{docCommand}{DriverCounterInfoColor}{} +This macro holds the text color for a driver counter, it defaults to \meta{\textcolor{\DriverCounterInfoColor}{\expandafter{\DriverCounterInfoColor}}}% +\end{docCommand} + +\begin{docCommand}{AssociatedCounterInfoColor}{} +This macro holds the text color for an associated counter, it defaults to \meta{\textcolor{\AssociatedCounterInfoColor}{\expandafter\AssociatedCounterInfoColor}}% +\end{docCommand} + +\begin{dispExample} + \PrettyPrintCounterName[countertype=general]{equation} +\end{dispExample} + + + +\section{Suspending and resuming associated counters}\label{section::suspendedresumedcounters} + +Rather than remove an associated counter from the list, it is possible to suspend the automatic stepping for a while and then resume it, for example, if the value of a counter should not be stepped within a specific chapter etc. + +\begin{docCommand}{SuspendCounters}{\oarg{options}\marg{counters list}}% +\begin{docCommandArgs}{SuspendCounters}% + +\begin{enumerate}[label={\textcolor{blue}{\#\arabic*}}] +\item \oarg{options}% + + Not used so far, reserved for later usages + +\item \marg{counters list}% + + Contains the name of counters to be suspended, separated by commas (CSV - list) +\end{enumerate} + +\end{docCommandArgs} + +Some remarks: + +\begin{itemize} +\item +Please note, that it is possible, to suspend an arbitrary counter, if the package option \refKey{globalsuspend} is set to \meta{true}. Handle this option with care! +\item If a driver counter is suspended, all counters associated to it are suspended too! +\end{itemize}% + +\begin{dispExample} +\textbf{This example shows 4 equations, but only two of them are counted} +\newtotcounter{totalequations} +\DeclareAssociatedCounters{equation}{totalequations} + +\begin{equation} +E_{0} = mc^2 +\end{equation} + +Now suspend the totalequations: + +\SuspendCounters{totalequations} +\begin{equation} +E^2 = \left({ pc}\right)^2 + E^{2}_{0} +\end{equation} + +\begin{equation} + m(v) = \frac{m_{0}}{\sqrt{1-\frac{v^2}{c^2}}} +\end{equation} + +And resume it: \ResumeSuspendedCounters + +\begin{equation} + E = h \nu +\end{equation} + +There are \number\totvalue{totalequations}~ equations in here! + + +\end{dispExample} + + +\end{docCommand}% + +\begin{docCommand}{ResumeSuspendedCounters}{} + This command has no arguments and revokes the suspension of \textbf{all} counters. +\end{docCommand} + + \section{Internals commands} @@ -487,15 +706,28 @@ This macro generates a list from the driver counter name and the driver counter \end{docCommand} - +\clearpage \section{To do list} \begin{itemize} \item Check the existence of driver and associated counters +\item Provide a better internal list organization +\item Some macro names might be non-intuitive \item Improve documentation \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@siebenfelsen.de\makeatother + \clearpage \section{Acknowledgments} @@ -536,8 +768,13 @@ This document has \number\totvalue{totalsections} section(s)% In this example, the subsections of this document are counted but later on, the associatedcounter is removed from the list, so it is frozen. +%\DeclareAssociatedCounters{subsection}{totalsubsections}% + +%\renewcommand{\DeclareAssociatedCounters}[3]{\relax}% + \begin{dispExample} \newtotcounter{totalsubsections}% +\newtotcounter{othertotalsubsections}% \DeclareAssociatedCounters{subsection}{totalsubsections}% \subsection{First dummy subsection} @@ -545,13 +782,12 @@ SubSection counter: \thesubsection~-- \number\totvalue{totalsubsections} \subsection{Second dummy subsection} SubSection counter: \thesubsection~-- \number\totvalue{totalsubsections} -\RemoveAssociatedCounter{subsection}{totalsubsections} - +\RemoveAssociatedCounter{subsection}{totalsubsections}% \subsection{Third dummy subsection after removing the associated counter} -SubSection counter: \thesubsection~-- \number\totvalue{totalsubsections} -\end{dispExample} +SubSection counter: \thesubsection~-- \number\totvalue{totalsubsections} +\end{dispExample} \section[Total number of proofs]{Example: Total number of proofs} @@ -559,8 +795,9 @@ SubSection counter: \thesubsection~-- \number\totvalue{totalsubsections} \begin{dispExample} % \usepackage{amsthm} is needed \newcounter{proof}% +\newtotcounter{anotherproofcounter}% \newtheorem{Proof}[proof]{Proof}% -\DeclareAssociatedCounters{proof}{totalproofs} +\DeclareAssociatedCounters{proof}{totalproofs,anotherproofcounter} \begin{Proof} It's trivial. \end{Proof} @@ -578,8 +815,37 @@ See excavations! \end{align*} \end{Proof} -This document has \number\totvalue{totalproofs} proofs % +This document has \number\value{anotherproofcounter} proofs % +Now let us manipulate the counter proof again: +\setcounter[AssociatedCounters={totalproofs}]{proof}{200} + +This document has \number\totvalue{totalproofs} (manipulated counter) proofs where as the unmanipulated counter still shows \number\value{anotherproofcounter} proofs % +\end{dispExample} + +This example shows, that the usage of the options to \cs{setcounter} should be used with care! + + +\subsection{Suspension of a non-associated counter} +This example will show the suspension of a non-associated counter + + +\begin{dispExample} +\setcounter{equation}{0}% +\SuspendCounters{equation}% +\begin{equation} +E_{0} = mc^2 +\end{equation} + +\begin{equation} +E^2 = \left({ pc}\right)^2 + E^{2}_{0} +\end{equation} + +\begin{equation} + m(v) = \frac{m_{0}}{\sqrt{1-\frac{v^2}{c^2}}} +\end{equation} + +There are \number\value{equation}~equations in here! \end{dispExample} diff --git a/Master/texmf-dist/tex/latex/assoccnt/assoccnt.sty b/Master/texmf-dist/tex/latex/assoccnt/assoccnt.sty index 08697e37332..1a08056afd3 100644 --- a/Master/texmf-dist/tex/latex/assoccnt/assoccnt.sty +++ b/Master/texmf-dist/tex/latex/assoccnt/assoccnt.sty @@ -1,26 +1,52 @@ \NeedsTeXFormat{LaTeX2e}% -\ProvidesPackage{assoccnt}[2014/08/21 v0.3 -- Associate counters stepping]% +\ProvidesPackage{assoccnt}[2014/09/01 v0.4 -- Associate counters stepping]% %%% %% License: LaTeX Project Public License %% Copyright (2014) Dr. Christian Hupfer -%% Author: Christian Hupfer christian.hupfer@siebenfelsen.de +%% Author: Christian Hupfer christian.hupfer@yahoo.de %% %%%% %%% Some options later on %%%% +\def\@@assoccnt@@keys{assoccntkeyfamily}% + +\def\@@assoccnt@@packagename{assoccnt.sty}% +\def\@@assoccnt@@keyprefix{@@assoccnt@@pkg@@}% + \RequirePackage{etoolbox}[2011/01/03 2.2]% \RequirePackage{xkeyval}[2012/10/14 v2.6b]% +\RequirePackage{xstring}% + +%%%% Defining package options + +\newtoggle{GlobalSuspend}% +\settoggle{GlobalSuspend}{false}% + + +% Option for enabling the global suspend facility for an arbitray counters +\define@boolkey{\@@assoccnt@@packagename}[@@assoccnt@@pkg@@]{globalsuspend}[false]{% + \if@@assoccnt@@pkg@@globalsuspend% + \toggletrue{GlobalSuspend}% + \else% + \togglefalse{GlobalSuspend}% + \fi% +}% +\DeclareOptionX*{\PackageWarning{\@@assoccnt@@packagename}{Option '\CurrentOption ' ignored}}% -\def\@@assoccnt@@keys{@@assoccnt@@keyfamily}% +\ProcessOptionsX% + +%%%%% \newcounter{@@assoccnt@@internalcounter}% \let\@@assoccnt@@standardstepcounter\stepcounter% \let\@@assoccnt@@standardrefstepcounter\refstepcounter% +\let\@@assoccnt@@standardsetcounter\setcounter% +\let\@@assoccnt@@standardaddtocounter\addtocounter% % Just for a quick suffix @@ -85,22 +111,21 @@ AssociatedCountersList% \newcommand{\@@assoccnt@@addassociatedcounter}[3][]{% - \ifcsdef{\@@assoccnt@@generateboundtocounterslist{#3}}{% - % The counter is already to some other counter, it should not be multiply associated! - }{% - \csgdef{\@@assoccnt@@generateboundtocounterslist{#3}}{}% - \listcsgadd{\@@assoccnt@@generateboundtocounterslist{#3}}{#1} - \ifcsdef{#2}{% - \ifinlistcs{#3}{#2}{% - % Do nothing, since counter is already in the list, prevent multiple list insertion - }{% - \listcsgadd{#2}{#3}% - }% + \ifcsdef{#2}{% + % driver counter list exists, check, whether it is already there + \ifinlistcs{#3}{#2}{% + % Do nothing, since counter is already in the list, prevent multiple list insertion }{% - % Nothing in here + \listcsgadd{#2}{#3}% + \listcsgadd{\@@assoccnt@@generateboundtocounterslist{#3}}{#1} }% + }{% + \listcsgadd{\@@assoccnt@@generatelistname{#1}}{#3}% + \listcsgadd{\@@assoccnt@@generateboundtocounterslist{#3}}{#1}% }% -}% +}% + + @@ -108,7 +133,7 @@ AssociatedCountersList% % #1 --> options % #2 --> driver counter % #3 --> CSV list of counters, that should be stepped, if the driver counter is stepped -\setkeys{\@@assoccnt@@keys}{#1}% + \setkeys{\@@assoccnt@@keys}{#1}% \ifcsdef{\@@assoccnt@@generatelistname{#2}}{% % % Nothing to be done --> List already exists \forcsvlist{\@@assoccnt@@addassociatedcounter[#2]{\@@assoccnt@@generatelistname{#2}}}{#3}% @@ -126,13 +151,13 @@ AssociatedCountersList% % #1 --> options % #2 --> driver counter % #3 --> CSV list of other counters, that should be stepped, if the driver counter is stepped -\setkeys{\@@assoccnt@@keys}{#1}% + \setkeys{\@@assoccnt@@keys}{#1}% \ifcsdef{\@@assoccnt@@generatelistname{#2}}{% % % Nothing to be done --> List already exists \GenericWarning{}{Warning: List of associated counters for driver counter #2 already exists}% }{% \AddDriverCounter{#2}% - \csgdef{\@@assoccnt@@generatelistname{#2}}{}% Define some global list + \listcsgadd{\@@assoccnt@@generatelistname{#2}}{}% Define some global list }% % Now add the counter names from #3 to the list % Note: Currently, it is not checked whether a counter is already added! @@ -141,6 +166,7 @@ AssociatedCountersList% \RemoveAssociatedCounter{#2}{#2}% }% +% Later on %\@onlypreamble{\DeclareAssociatedCounters}% @@ -148,22 +174,45 @@ AssociatedCountersList% + +\newcommand{\@@assoccnt@@copylist}[2]{% + \ifstrequal{#1}{#2}{% + % Nothing to be done + }{% + \csundef{#2}% + \renewcommand*{\do}[1]{% + \listcsgadd{#2}{##1}% + }% + \dolistcsloop{#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\@@assoccnt@@mytemplist{}% + \ifcsdef{@@assoccnt@@templist}{% + \csundef{@@assoccnt@@templist}% + }{}% + \listcsgadd{@@assoccnt@@templist}{}% + \@@assoccnt@@standardsetcounter{@@assoccnt@@internalcounter}{0}% \renewcommand*{\do}[1]{% - \ifstrequal{##1}{#2}{ + \ifstrequal{##1}{#2}{% % Later one some success routine etc. ??? }{% - \listgadd{\@@assoccnt@@mytemplist}{##1}% + \listcsgadd{@@assoccnt@@templist}{##1}% + \@@assoccnt@@standardstepcounter{@@assoccnt@@internalcounter}% }% }% \dolistcsloop{#1}% - \csxdef{#1}{\@@assoccnt@@mytemplist}% + \csundef{#1}% + \ifnumgreater{\number\value{@@assoccnt@@internalcounter}}{0}{% + \@@assoccnt@@copylist{@@assoccnt@@templist}{#1}% + }{}% }{% % The list is not defined at all, can't remove something from something not existing... }% @@ -176,6 +225,7 @@ AssociatedCountersList% % #1 arg: driver counter % #2 arg: counter name to be removed \@@assoccnt@@removefromlist{\@@assoccnt@@generatelistname{#1}}{#2}% + \@@assoccnt@@removefromlist{\@@assoccnt@@generateboundtocounterslist{#1}}{#2}% }% %% Remove a CSV list of counters from the list of associated counters @@ -230,6 +280,61 @@ AssociatedCountersList% }% +\newcommand{\@@assoccnt@@itemizedshowassociatedcounters}[1]{% + \begin{itemize} + \renewcommand*{\do}[1]{% + \item \@@assoccnt@@showassociatedcounterlist{##1} -- \fbox{\number\value{##1}}% + }% + \dolistcsloop{\@@assoccnt@@generatelistname{#1}}% + \end{itemize}% +}% + +\newcommand{\GeneralCounterInfoColor}{orange} +\newcommand{\DriverCounterInfoColor}{blue} +\newcommand{\AssociatedCounterInfoColor}{red} + +\define@key{\@@assoccnt@@keys}{countertype}[driver]{% + \def\@@assoccnt@@keymacro@@countertype{#1}% +}% + + +\newcommand{\PrettyPrintCounterName}[2][countertype={general}]{% + \setkeys{\@@assoccnt@@keys}{#1}% + \IfStrEq{\@@assoccnt@@keymacro@@countertype}{driver}{% + \fbox{\textcolor{\DriverCounterInfoColor}{\textbf{#2{}}}}% + }{% + \IfStrEq{\@@assoccnt@@keymacro@@countertype}{associated}{% + \fbox{\textcolor{\AssociatedCounterInfoColor}{\textbf{#2{}}}}% + }{% + \fbox{\textcolor{\GeneralCounterInfoColor}{\textbf{#2}}}% + }% + }% +}% + + +\newcommand{\AssociatedDriverCounterInfo}[1]{% + \textbf{Associated/Driver counter information on counter \PrettyPrintCounterName[countertype=general]{#1}}\par + \IsAssociatedCounter{#1}{% + Counter \PrettyPrintCounterName[countertype=associated]{#1} is associated to \PrettyPrintCounterName[countertype=driver]{\GetDriverCounter{#1}}% + \IsDriverCounter{#1}{% + Counter \PrettyPrintCounterName[countertype=driver]{#1} is driver counter of + \@@assoccnt@@itemizedshowassociatedcounters{#1}% + % + }{}% + }{% + \IsDriverCounter{#1}{% + Counter \PrettyPrintCounterName[countertype=driver]{#1} is driver counter of + \@@assoccnt@@itemizedshowassociatedcounters{#1}% + }{% + Counter \PrettyPrintCounterName[countertype=general]{#1} is neither driver nor associated counter % + }% + }% +}% + + + + + \newcommand{\GetDriverCounter}[1]{% \setcounter{@@assoccnt@@internalcounter}{0}% \renewcommand*{\do}[1]{% @@ -243,7 +348,7 @@ AssociatedCountersList% }% \newcommand{\@@assoccnt@@showassociatedcounterlist}[1]{% - \textcolor{red}{\textbf{#1{ }}}% + \PrettyPrintCounterName[countertype=associated]{\textbf{#1{ }}}% }% \newcommand{\@@assoccnt@@showdrivercounterlist}[1]{% @@ -259,6 +364,35 @@ AssociatedCountersList% }% +\define@key{\@@assoccnt@@keys}{SuspendCounters}{% + \def\@@assoccnt@@keymacro@@suspendedcounters{#1}% + \forcsvlist{\listgadd{\@@assoccnt@@suspendedcounterslist}}{#1}% +}% + + +% A convenience macro -- do not change% +\newcommand{\@@assoccnt@@wrapperaddsuspendedcounter}[1]{% + \listcsgadd{@@assoccnt@@suspendedcounterslist}{#1}% +}% + + +\newcommand{\SuspendCounters}[2][]{% + \forcsvlist{\@@assoccnt@@wrapperaddsuspendedcounter}{#2}% +}% + +%% Not much in here +\newcommand{\ResumeSuspendedCounters}{% + \undef{\@@assoccnt@@suspendedcounterslist}% +}% + + +\newcommand{\IsSuspendedCounter}[3]{% + \ifinlistcs{#1}{@@assoccnt@@suspendedcounterslist}{% + #2% + }{% + #3% + }% +}% %%% 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 @@ -266,36 +400,96 @@ AssociatedCountersList% \@@assoccnt@@standardstepcounter{#1}% }% +%%% The setcounter wrapper +\newcommand{\@@assocccnt@@setcounter}[2]{% + \@@assoccnt@@standardsetcounter{#1}{#2}% +}% + +%%% addtocounter wrapper -- needs to switch the arguments for the command for the list usage!!! +\newcommand{\@@assoccnt@@addtocounter}[2]{% + \ifcsdef{@@assoccnt@@suspendedcounterslist}{% + % Now, there are suspended counters -- do not update them! + \IsSuspendedCounter{#2}{% + % Nothing to be done + }{% + \@@assoccnt@@standardaddtocounter{#2}{#1}% + }% + }{% + \@@assoccnt@@standardaddtocounter{#2}{#1}% + }% +}% + +%%% addtocounter wrapper -- needs to switch the arguments for the command for the list usage!!! +\newcommand{\@@assoccnt@@setcounter}[3]{% + \IsAssociatedToCounter{#1}{#3}{% + \@@assoccnt@@standardsetcounter{#3}{#2}% + }{% + \GenericWarning{}{Warning: Counter "#3" is not part of the associated list counters to driver counter "#1"}% + }% +}% + + + %%% Not needed so far -\newcommand{\@@assoccnt@refstepcounter}[1]{% +\newcommand{\@@assoccnt@@refstepcounter}[1]{% \@@assoccnt@@standardrefstepcounter{#1}% }% -%%%% Redefinition of the \stepcounter command -\renewcommand{\stepcounter}[1]{% - \@@assoccnt@@standardstepcounter{#1}% Traditional behaviour, since this is expected! + + +\renewcommand{\addtocounter}[2]{% + \iftoggle{GlobalSuspend}{% + \IsSuspendedCounter{#1}{% + % No, do nothing at all% + }{% + \@@assoccnt@@standardaddtocounter{#1}{#2}% + } + }{% + \@@assoccnt@@standardaddtocounter{#1}{#2}% + }% \ifcsdef{\@@assoccnt@@generatelistname{#1}}{% Check first, whether the list exists at all, - \forlistcsloop{\@@assoccnt@@stepcounter}{\@@assoccnt@@generatelistname{#1}}% March through the list + \forlistcsloop{\@@assoccnt@@addtocounter{#2}}{\@@assoccnt@@generatelistname{#1}}% March through the list }{% - %No list -> do nothing at all + % No list -> do nothing at all }% }% +\listgadd{\@@assoccnt@@tempcounterlist}{}% This should be renamed later one... treated more generally +\newcommand{\@@assoccnt@@setcounterwrapper}[3]{% + \ifcsdef{\@@assoccnt@@generatelistname{#1}}{% Check first, whether the per driver list exists at all, + \forlistcsloop{\@@assoccnt@@setcounter{#1}{#2}}{#3}% + }{}% +}% +\define@boolkey{\@@assoccnt@@keys}{AssociatedToo}[false]{% +}% -%%%% 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 - }% + + +\define@key{\@@assoccnt@@keys}{AssociatedCounters}{% + \undef{\@@assoccnt@@tempcounterlist}% + \def\@@assoccnt@@keymacro@@associatedcounters{#1}% + \forcsvlist{\listgadd{\@@assoccnt@@tempcounterlist}}{#1}% }% +%% Redefined \setcounter -- with additional optional key% + +\renewcommand{\setcounter}[3][]{% + \@@assoccnt@@standardsetcounter{#2}{#3}% + \setkeys{\@@assoccnt@@keys}{AssociatedToo=false,#1}% + \ifKV@assoccntkeyfamily@AssociatedToo + \@@assoccnt@@setcounterwrapper{#2}{#3}{\@@assoccnt@@generatelistname{#2}}% + \else% + \ifdef{\@@assoccnt@@keymacro@@associatedcounters}{% + \@@assoccnt@@setcounterwrapper{#2}{#3}{@@assoccnt@@tempcounterlist}% + \undef{\@@assoccnt@@tempcounterlist}% Clear the counter list + \listgadd{\@@assoccnt@@tempcounterlist}{}% Redefine the list for future use% + \undef{\@@assoccnt@@keymacro@@associatedcounters}% + }{}% + \fi% +}% + \endinput%
\ No newline at end of file |