| 1 |
%% LaTeX package xassoccnt - version 2.0 (2021/11/21 -- 12:14:58) |
| 2 |
%% Driver file for xassoccnt.sty |
| 3 |
%% |
| 4 |
%% |
| 5 |
%% ------------------------------------------------------------------------------------------- |
| 6 |
%% Copyright (c) 2015 -- 2021 by Dr. Christian Hupfer <> |
| 7 |
%% ------------------------------------------------------------------------------------------- |
| 8 |
%% |
| 9 |
%% This work may be distributed and/or modified under the |
| 10 |
%% conditions of the LaTeX Project Public License, either version 1.3 |
| 11 |
%% of this license or (at your option) any later version. |
| 12 |
%% The latest version of this license is in |
| 13 |
%% http://www.latex-project.org/lppl.txt |
| 14 |
%% and version 1.3 or later is part of all distributions of LaTeX |
| 15 |
%% version 2005/12/01 or later. |
| 16 |
%% |
| 17 |
%% |
| 18 |
%% This work has the LPPL maintenance status `unmaintained` |
| 19 |
%% |
| 20 |
%% |
| 21 |
|
| 22 |
\documentclass{book} |
| 23 |
|
| 24 |
\usepackage{xcolor} |
| 25 |
\usepackage{totcount} |
| 26 |
\usepackage{calc} |
| 27 |
\usepackage[autodefinecounters=false]{xassoccnt} |
| 28 |
|
| 29 |
|
| 30 |
\usepackage{hyperref} |
| 31 |
\usepackage{cleveref} |
| 32 |
|
| 33 |
|
| 34 |
\newcounter{newtotalpages} |
| 35 |
\newtotcounter{totalsections} |
| 36 |
\newcounter{othersections} |
| 37 |
\newtotcounter{totaltables} |
| 38 |
|
| 39 |
\NewTotalDocumentCounter{equations} |
| 40 |
|
| 41 |
\DeclareAssociatedCounters[autodefine=none]{section}{totalsections,othersections,equations} |
| 42 |
\AddAssociatedCounters{section}{totalsections} |
| 43 |
|
| 44 |
|
| 45 |
\DeclareAssociatedCounters{page}{newtotalpages} |
| 46 |
\DeclareAssociatedCounters{table}{totaltables} |
| 47 |
|
| 48 |
|
| 49 |
\begin{document} |
| 50 |
\chapter{First} |
| 51 |
|
| 52 |
In \cref{section::dummylabel} we will see that |
| 53 |
|
| 54 |
\section{First} |
| 55 |
|
| 56 |
\begin{table} |
| 57 |
\caption{table} |
| 58 |
\end{table} |
| 59 |
|
| 60 |
|
| 61 |
\begin{table} |
| 62 |
\caption{table} |
| 63 |
\end{table} |
| 64 |
|
| 65 |
|
| 66 |
\begin{table} |
| 67 |
\caption{table} |
| 68 |
\end{table} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
\section{Other} |
| 73 |
\section{Third} |
| 74 |
|
| 75 |
\begin{table} |
| 76 |
\caption{Other table} |
| 77 |
\end{table} |
| 78 |
|
| 79 |
\begin{equation} |
| 80 |
E=mc^2 |
| 81 |
\end{equation} |
| 82 |
|
| 83 |
\begin{equation} |
| 84 |
E=mc^2 |
| 85 |
\end{equation} |
| 86 |
|
| 87 |
|
| 88 |
\TotalValue{equations} |
| 89 |
|
| 90 |
\chapter{Second chapter} |
| 91 |
|
| 92 |
\section{First section of 2nd chapter} \label{section::dummylabel} |
| 93 |
|
| 94 |
\thesection\ \total{totalsections}\ \theothersections\ \fbox{\color{blue}{\thetotaltables}} |
| 95 |
|
| 96 |
|
| 97 |
\IsSuspendedCounter{totalsections}{Yes, it's suspended}{Nope, it's not suspended} |
| 98 |
|
| 99 |
\IsAssociatedCounter{totalsections}{Yes, it's associated}{Nope, it's not associated} |
| 100 |
|
| 101 |
\IsSuspendedCounter{equation}{Yes, it's suspended}{Nope, it's not suspended} |
| 102 |
|
| 103 |
\IsAssociatedCounter{equation}{Yes, it's associated}{Nope, it's not associated} |
| 104 |
|
| 105 |
|
| 106 |
\TotalValue{equations} |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
\TotalValue{equations} |
| 111 |
|
| 112 |
|
| 113 |
\SetDocumentCounter{section}{28} |
| 114 |
|
| 115 |
\SetDocumentCounter{totalsections}{100} |
| 116 |
|
| 117 |
\NewDocumentCounter[initial=151]{counterother}[section] |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
Value of counterother: \thecounterother |
| 122 |
|
| 123 |
\section{Another one} |
| 124 |
|
| 125 |
Value of counterother: \thecounterother |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
\thesection\ \thetotalsections\ \theothersections\ \fbox{\color{blue}{\thetotaltables}}\ |
| 132 |
|
| 133 |
\SyncCounters[onlycounters={totalsections}]{section} |
| 134 |
|
| 135 |
|
| 136 |
\IfIsDocumentCounterTF{section}{% |
| 137 |
Yes, it's a counter |
| 138 |
}{% |
| 139 |
No, it's no counter |
| 140 |
} |
| 141 |
|
| 142 |
|
| 143 |
\IsSuperTotalCounterT{numberofruns}{% |
| 144 |
Yes, numberofruns is a super total counter |
| 145 |
} |
| 146 |
|
| 147 |
\IsSuperTotalCounterF{chapter}{% |
| 148 |
No, chapter is not a super total counter |
| 149 |
} |
| 150 |
|
| 151 |
|
| 152 |
\countersresetlistcount{chapter} |
| 153 |
\SetDocumentCounter{counterother}{\getresetlistcount} |
| 154 |
|
| 155 |
\begin{itemize} |
| 156 |
\item There are \getresetlistcount\ counters in the reset list of chapter |
| 157 |
\item \IfInResetListTF{chapter}{figure}{Yes, figure is in the reset list of chapter}{No, figure is not in the reset list of chapter} |
| 158 |
\item \IfInResetListTF{chapter}{page}{Yes, page is in the reset list of chapter}{No, page is not in the reset list of chapter} |
| 159 |
\item Values: \thesection\ \total{totalsections}\ \theothersections\ \fbox{\color{blue}{\total{totaltables}}}\ \thecounterother. |
| 160 |
\end{itemize} |
| 161 |
|
| 162 |
Total value of equations: \TotalValue{equations} |
| 163 |
|
| 164 |
Internal name: \TotalCounterInternalName{equations} |
| 165 |
|
| 166 |
\begin{table} |
| 167 |
\caption{table} |
| 168 |
\end{table} |
| 169 |
|
| 170 |
|
| 171 |
%\stepcounter{equations} |
| 172 |
|
| 173 |
|
| 174 |
\chapter{Another chapter} |
| 175 |
|
| 176 |
\PrettyPrintCounterName{countertype=general}{equation} |
| 177 |
\PrettyPrintCounterName{countertype=driver}{chapter} |
| 178 |
\PrettyPrintCounterName{countertype=associated}{totalsections} |
| 179 |
\PrettyPrintCounterName{countertype=total}{equations} |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
\begin{table} |
| 184 |
\caption{table} |
| 185 |
\end{table} |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
\chapter{A new chapter} |
| 190 |
|
| 191 |
\begin{equation} |
| 192 |
E=mc^2 |
| 193 |
\end{equation} |
| 194 |
|
| 195 |
\chapter{Another new chapter} |
| 196 |
|
| 197 |
\begin{equation} |
| 198 |
E=mc^2 |
| 199 |
\end{equation} |
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
\end{document} |