summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.tex
blob: 3a5b64b14dc600f909ad35987c518e523f8d1377 (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
%% LaTeX package xassoccnt driver file - version 0.1 (2015/11/07)
%%
%%
%%
%% -------------------------------------------------------------------------------------------
%% Copyright (c) 2015 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'.
%%
%% This work consists of all files listed in README
%%


\documentclass{book}

\usepackage{xcolor}

\usepackage{calc}
\usepackage[autodefinecounters=true]{xassoccnt}

\usepackage{totcount}
\usepackage{hyperref}
\usepackage{cleveref}


\newcounter{totalpages}
\newtotcounter{totalsections}
\newcounter{othersections}



\DeclareAssociatedCounters[autodefine=none]{section}{totalsections,othersections}
\AddAssociatedCounters[autodefine=associated]{section}{totalsections}


\DeclareAssociatedCounters{page}{totalpages}
\DeclareAssociatedCounters[autodefine=associated,sloppy=false]{table}{totaltables}



\begin{document}


\chapter{First}

In \cref{section::dummylabel} we will see that

\section{First}

\begin{table}
\caption{table}
\end{table}



\section{Other}
\section{Third}

\begin{table}
\caption{Other table}
\end{table}

\begin{equation}
  E=mc^2
\end{equation}

\begin{equation}
  E=mc^2
\end{equation}


\chapter{Second chapter}

\section{First section of 2nd chapter} \label{section::dummylabel}

\thesection\ \total{totalsections}\ \theothersections\ \thetotaltables\ 


\IsSuspendedCounter{totalsections}{Yes, it's suspended}{Nope, it's not suspended}

\IsAssociatedCounter{totalsections}{Yes, it's associated}{Nope, it's not associated}

\IsSuspendedCounter{equation}{Yes, it's suspended}{Nope, it's not suspended}

\IsAssociatedCounter{equation}{Yes, it's associated}{Nope, it's not associated}


\SetDocumentCounter[associatedtoo=true,onlycounters={totalsections,gandalf},associatedtoo=true]{section}{17}

\SetDocumentCounter{section}{28}

\SetDocumentCounter{totalsections}{100}

\NewDocumentCounter[initial=151]{counterother}[section]



Value of counterother: \thecounterother

\section{Another one}

Value of counterother: \thecounterother





\thesection\ \thetotalsections\ \theothersections\ \thetotaltables\ 

\SyncCounters[onlycounters={totalsections}]{section}


\IfIsDocumentCounterTF{section}{%
  Yes, it's a counter
}{%
  No, it's no counter
}


\countersresetlistcount{chapter}
\SetDocumentCounter{counterother}{\getresetlistcount}

\begin{itemize}
  \item There are \getresetlistcount\  counters in the reset list of chapter
  \item \IfInResetListTF{chapter}{figure}{Yes, figure is in the reset list of chapter}{No, figure is not in the reset list of chapter}
  \item \IfInResetListTF{chapter}{page}{Yes, page is in the reset list of chapter}{No, page is not in the reset list of chapter}
  \item Values: \thesection\ \thetotalsections\ \theothersections\ \thetotaltables\ \thecounterother. 
\end{itemize}

\end{document}