summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_backupcounters_example.tex
blob: 8926bc4522587cfd5abd36eed8b5de58f8fa057c (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
%% LaTeX package xassoccnt - version 1.5 (2017/07/28 -- 12:08:57)
%% Example file for backup counters file for xassoccnt.sty
%%
%%
%% -------------------------------------------------------------------------------------------
%% Copyright (c) 2016 -- 2017 by Dr. Christian Hupfer <typography dot with dot latex at gmail dot com>
%% -------------------------------------------------------------------------------------------
%%
%% 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{book}

\usepackage{xassoccnt}
\usepackage{blindtext}
%\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}
\usepackage{hyperref}

\DeclareBackupCountersGroupName{sectiontree}
\DeclareBackupCountersGroupName{chaptertree}

\AssignBackupCounters[name=chaptertree,cascading=true]{chapter} % Use all counters in the chapter counter driver reset list


\newcommand{\outputit}[1]{\csname the#1\endcsname\par}

\begin{document}
Checking for existence of a backup counter group:


\IsBackupCounterGroupTF{chaptertree}{Yes, \fbox{chaptertree} is a backup counter group}{no, \fbox{chaptertree} is no backup counter group}

\IsBackupCounterGroupT{chaptertree}{Yes, \fbox{chaptertree} is a backup counter group}

\IsBackupCounterGroupF{foochaptertree}{No, \fbox{foochaptertree} is no backup counter group}

\IsBackupCounterGroupTF{secondchaptertree}{Yes, \fbox{secondchaptertree} is a backup counter group}{no, \fbox{secondchaptertree} is no backup counter group}
\clearpage
\tableofcontents
\listoffigures

\chapter{First regular chapter}

\section{First section in first regular chapter}

\subsection{First subsection in first regular section}



\begin{figure}
\caption{My nice figure in 1st regular chapter}
\end{figure}


\begin{figure}
\caption{My other nice figure in 1st regular chapter}
\end{figure}



\chapter{Second regular chapter}

\section{First section in 2nd regular chapter}

\subsection{1st subsection in 1st regular section of 2nd regular chapter}


\begin{figure}
\caption{My nice figure in 2nd regular chapter}
\end{figure}


\begin{figure}
\caption{My other nice figure in 2nd regular chapter}
\end{figure}





\chapter{Third regular chapter}

\section{1st section in 3rd regular chapter}

\subsection{1st subsection in 1st regular section of 2nd regular chapter}
\subsection{2nd subsection in 1st regular section of 2nd regular chapter}

\section{2nd section in 3rd regular chapter}

\subsection{1st subsection in 2nd regular section of 2nd regular chapter}
\subsection{2nd subsection in 2nd regular section of 2nd regular chapter}

\chapter{Fourth regular chapter}



\BackupCounterGroup[backup-id={firstchaptertree},cascading=true]{chaptertree}



\chapter{First chapter after backup command}

\section{1st section in 1st backup chapter}

\subsection{1st subsection in 1st regular section of 1st backup chapter}
\subsection{2nd subsection in 1st regular section of 1st backup chapter}

\section{2nd section in 1st backup chapter}

\subsection{1st subsection in 2nd regular section of 1st backup chapter}
\subsection{2nd subsection in 2nd regular section of 1st backup chapter}


\begin{figure}
\caption{My nice figure in 1st backup chapter}
\end{figure}


\begin{figure}
\caption{My other nice figure in 1st backup chapter}
\end{figure}





\chapter{Second chapter after backup command}

\section{1st section in 2nd backup chapter}

\subsection{1st subsection in 1st regular section of 2nd backup chapter}
\subsection{2nd subsection in 1st regular section of 2nd backup chapter}

\section{2nd section in 2nd backup chapter}

\subsection{1st subsection in 2nd regular section of 2nd backup chapter}
\subsection{2nd subsection in 2nd regular section of 2nd backup chapter}


\chapter{Third chapter after first backup command}



\BackupCounterGroup[backup-id={secondchaptertree}]{chaptertree}

\chapter{First chapter after second backup command}

% Now restore the full chaptertree command with the backup id firstchaptertree, but don't keep the state afterwards. 

Checking the backup state: \IsBackupStateTF{chaptertree}{firstchaptertree}{Yes}{No}

Checking the backup state again: \IsBackupStateT{chaptertree}{firstchaptertree}{Yes}

Checking the backup state again: \IsBackupStateF{chaptertree}{foochaptertree}{No, it's no backup state}


\RestoreBackupCounterGroup[keep-after-restore=false,backup-id={firstchaptertree}]{chaptertree}

Now checking after restore with `keep-after-restore=false`:

Checking the backup state: \IsBackupStateTF{chaptertree}{firstchaptertree}{Yes}{No}

Checking the backup state again: \IsBackupStateT{chaptertree}{firstchaptertree}{Yes}

Checking the backup state again: \IsBackupStateF{chaptertree}{foochaptertree}{No, it's no backup state}





\chapter{First chapter after restoring of first backup}


\section{1st section in 1st backup chapter of 2nd backup}

\subsection{1st subsection in 1st regular section of 2nd backup chapter}
\subsection{2nd subsection in 1st regular section of 2nd backup chapter}

\section{2nd section in 2nd backup chapter of 2nd backup}

\subsection{1st subsection in 2nd regular section of 2nd backup chapter}
\subsection{2nd subsection in 2nd regular section of 2nd backup chapter}


\chapter{Another chapter after restoring}

% Now let us restore only some of the counters


\section{First section of another chapter}

\begin{figure}
\caption{My nice figure}
\end{figure}

\begin{figure}
\caption{My very nice figure}
\end{figure}


\subsection{First subsection of 1st section of another chapter}

\section{Now another section}


\RestoreBackupCounterGroup[keep-after-restore=true,backup-id={secondchaptertree}]{chaptertree}


\chapter{Another chapter after restoring with secondchaptertree}

% Now let us restore only some of the counters


\section{First section of another chapter}

\begin{figure}
\caption{My nice figure}
\end{figure}

\begin{figure}
\caption{My very nice figure}
\end{figure}


\subsection{First subsection of 1st section of another chapter}

\section{Now another section}


\RestoreBackupCounterGroup[keep-after-restore=true,backup-id={secondchaptertree},restore-id=first]{chaptertree}


\chapter{Another chapter after restoring, secondchaptertree,other restore-id}

% Now let us restore only some of the counters


\section{First section of another chapter}

\begin{figure}
\caption{My nice figure}
\end{figure}

\begin{figure}
\caption{My very nice figure}
\end{figure}


\subsection{First subsection of 1st section of another chapter}

\section{Now another section}

\RestoreBackupCounterGroup[keep-after-restore=true,backup-id={secondchaptertree},restore-id=newrestore]{chaptertree}


\chapter{Another chapter after restoring, secondchaptertree, yet another restore-id}

% Now let us restore only some of the counters


\section{First section of another chapter}

\begin{figure}
\caption{My nice figure}
\end{figure}

\begin{figure}
\caption{My very nice figure}
\end{figure}


\subsection{First subsection of 1st section of another chapter}

\section{Now another section}


%%%%%


%\ClearBackupCounterGroups{chaptertree}

%\DeleteBackupCounterGroups{chaptertree}


\RemoveCountersFromBackupGroup{chaptertree}{section}




\RestoreBackupCounterGroup[keep-after-restore=true,backup-id={secondchaptertree},restore-id=renewrestore]{chaptertree}

%\chapter{Another chapter after restoring, secondchaptertree, yet another restore-id}



Removing a specific backup-id

%\ClearCounterBackupState[backup-id=secondchaptertree]{chaptertree}{chapter}


\ClearBackupState[backup-id=secondchaptertree]{chaptertree}



\section{First section of another chapter}

\begin{figure}
\caption{My nice figure}
\end{figure}

\begin{figure}
\caption{My very nice figure}
\end{figure}


\subsection{First subsection of 1st section of another chapter}

\section{Now another section}



\end{document}