Debian Codegraph @

texmf-dist/doc/latex/autonum/test-autonum.tex

raw
1 \documentclass{article}
2
3 % Load hyperref early to avoid an error on compilation without existing aux-file. This is in contrast to what is recommended in hyperref's documentation. When deleting the aux-file, there was an error on first compilation if hyperref was defined after the \AtEndDocument command below. But as the second compilation run without error and as the error also happened without autonum, this is a problem outside unrelated to autonum.
4 \usepackage[hypertexnames=false]{hyperref}
5
6 % Make this document look like endless paper to avoid page breaks, which make some of the tests useless.
7 % See http://tex.stackexchange.com/a/27057/7323
8 \usepackage{geometry}
9 \geometry{paperwidth=20cm,paperheight=\maxdimen,margin=4cm}
10 \usepackage{etoolbox}
11 \AtBeginDocument{
12 \setbox0=\vbox
13 \bgroup
14 }
15 \AtEndDocument{
16 \egroup
17 \dimen0=\dp0
18 \pdfpageheight=\dimexpr\ht0+10cm\relax
19 \unvbox0\kern-\dimen0
20 }
21
22 % \usepackage[english,ngerman]{babel}
23 % \usepackage[utf8]{inputenx}
24 % \usepackage[utf8x]{inputenx}
25
26 \usepackage{amsmath}
27 \usepackage{cleveref}
28 \usepackage{autonum}
29
30 % This package is not needed and can be uncommented at any time. Loading it ensures that conflicts between this package and autonum (being involved by loading etoolbox and etextools) are detected.
31 \usepackage[backend=bibtex]{biblatex}
32 % Deactivate a warning from biblatex, as the package is intentionally not used in this document.
33 \makeatletter
34 \def\blx@ifsigned#1#2#3#4{}%
35 \makeatother
36
37 \newcounter{Hequation}
38 \renewcommand{\theHequation}{\thechapter.\arabic{Hequation}}
39 \makeatletter
40 \g@addto@macro\equation{\stepcounter{Hequation}}
41
42 \listfiles
43
44 \@ifpackageloaded{autonum}{%
45 \def\ifautonum#1{#1}%
46 }{%
47 \def\ifautonum#1{}%
48 }
49
50 \@ifpackageloaded{cleveref}{%
51 \def\ifcleveref#1{#1}%
52 \crefname{inequation}{ineq.}{ineqs.}
53 }{%
54 \def\ifcleveref#1{}%
55 }
56
57 \makeatother
58
59 \begin{document}
60
61 % \tracingall
62 % \makeatletter
63 % \show\equation
64 % \show\autonum@equationOld
65 % \show\mathdisplay
66 % \show\mathdisplay@pop
67
68 % \begin{equation}\label{dd}a\end{equation}%\ref{dd}
69 % % \stop
70 % \begin{equation}\label{ee}b\end{equation}
71 \section*{Tests}
72 \begin{itemize}
73 \item Additionally, test that deactivating the package does not result in compile errors during the next run if only basic features are used.
74 \item Additionally, test that everything works with and without the above inputenx package (after deactivating the very strange label below).
75 \item Additionally, test test-freeze.tex.
76 \item Having a referenced equation with reference before \ref{referenceBefore}
77 \begin{equation}\label{referenceBefore}
78 d - d = 0
79 \end{equation}
80 \begin{equation}\label{referenceNo}
81 d - d = 0
82 \end{equation}
83 \ref{b}\begin{equation}\label{a}a\end{equation}\begin{equation}\label{b}b\end{equation}
84 \item Having a referenced equation with reference after
85 \begin{equation}\label{referenceAfter}
86 c^2 = c c
87 \end{equation}
88 \ref{referenceAfter}
89 \item Having an unlabeled equation
90 \begin{equation}
91 a^2 + b^2 = c^2
92 \end{equation}
93 \item Having a labeled equation with the label at the end of the equation \ref{abc}
94 \begin{equation}
95 a^2 + b^2 = c^2\label{abc}
96 \end{equation}
97 \item Having a labeled, but unreferenced equation
98 \begin{equation}\label{unreferenced}
99 \sqrt{a}
100 \end{equation}
101 \item Having a labeled equation with a very strange label \ref{äöüÄÖÜß?:, 3075µ!/§} does only work without package inputenx
102 \begin{equation}\label{äöüÄÖÜß?:, 3075µ!/§}
103 \sqrt{b}
104 \end{equation}
105 \item Having a labeled equation with a colon in the label \ref{label:colon}
106 \begin{equation}\label{label:colon}
107 \sqrt{c}
108 \end{equation}
109 \item Having an equation with a following label with a colon in the label \ref{labelAfter:colon}
110 \begin{equation}
111 \sqrt{d}\label{labelAfter:colon}
112 \end{equation}
113 \item Having an equation with a following label with a colon in the label
114 \begin{equation}
115 \sqrt{e}\label{referenceAfter:colon}
116 \end{equation}
117 and referencing \ref{referenceAfter:colon} only afterwards
118 \item Having a labeled equation with umlauts in the label \ref{äöüÄÖÜßLabel}
119 \begin{equation}\label{äöüÄÖÜßLabel}
120 \sqrt{c}
121 \end{equation}
122 \item Check for spurious whitespace around reference (\ref{checkWhitespace})
123 \begin{equation}\label{checkWhitespace}
124 b_c
125 \end{equation}
126 \item Check if the starred version of ref does also work (\ref*{checkStarred})
127 \begin{equation}\label{checkStarred}
128 c_D
129 \end{equation}
130 \ifcleveref{
131 \item Check if the starred version of cref does also work (\cref*{checkStarredCref})
132 \begin{equation}\label{checkStarredCref}
133 d_E
134 \end{equation}
135 }
136 \item Placing the number in long equations \ref{long}
137 \begin{equation}\label{long}
138 \sum\sum\sum\sum\sum\sum\sum\sum\sum\sum\sum\sum\sum\sum\sum\sum\sum\sum\sum a
139 \end{equation}
140 \ifautonum{
141 \item Printing the number without referencing (needs autonum)
142 \begin{equation+}
143 E = mgh
144 \end{equation+}
145 }
146 \item Using a ref inside a caption
147 \begin{figure}
148 ref
149 \caption{\ref{long}}
150 \end{figure}
151 \ifcleveref{
152 \item Using a cref inside a caption
153 \begin{figure}
154 cref
155 \caption{\cref{long}}
156 \end{figure}
157 \item Using cref with one argument
158 \begin{equation}\label{crefOne}
159 g
160 \end{equation}
161 \cref{crefOne}
162 \item Using cref with two arguments
163 \begin{equation}\label{crefTwo}
164 cr = ef
165 \end{equation}
166 \cref{crefOne,crefTwo}
167 \ifautonum{
168 \item Using otherwise unused cref with two arguments (needs autonum)
169 \[\label{crefThree}
170 cr = ef
171 \]
172 \[\label{crefFour}
173 cr = ef
174 \]
175 \cref{crefThree,crefFour}
176 }
177 \item Using cref with a custom type \cref{myInequation} and thus an optional argument in the label command
178 \begin{equation}\label[inequation]{myInequation}
179 a < b
180 \end{equation}
181 \item Using an unused cref with a custom type and thus an optional argument in the label command
182 \begin{equation}\label[inequation]{myUnusedInequation}
183 d < c
184 \end{equation}
185 }
186 \item Using align \ref{alignOne}, \ref{alignThree}
187 \begin{align}
188 a\label{alignOne}\\
189 b\label{alignTwo}\\
190 c\label{alignThree}
191 \end{align}
192 \item Using gather \ref{gatherOne}, \ref{gatherThree}
193 \begin{gather}
194 a\label{gatherOne}\\
195 b\label{gatherTwo}\\
196 c\label{gatherThree}
197 \end{gather}
198 \item Using multline without referencing
199 \begin{multline}
200 a\\
201 c\label{multlineUnreferenced}
202 \end{multline}
203 \item Using multline with referencing \ref{multlineReferenced}
204 \begin{multline}
205 a\\
206 c\label{multlineReferenced}
207 \end{multline}
208 \item Using flalign with referencing \ref{flalignReferenced}
209 \begin{flalign}
210 a\\
211 c\label{flalignReferenced}
212 \end{flalign}
213 \item Using alignat with referencing \ref{alignatReferenced}
214 \begin{alignat}{4}
215 x &= yy & \implies & y &= x \label{alignatUnreferenced}\\
216 y &= z & \implies & z &= y \label{alignatReferenced}
217 \end{alignat}
218 \item short one-line shortcut \[n\]
219 % \item shortcut environment with two lines, referencing \ref{firstShortcut} \[n_1\label{firstShortcut} \\ n_2\]
220 \ifautonum{
221 \item align, numbering always \begin{align+} a=l \end{align+} (needs autonum)
222 \item gather, numbering always \begin{gather+} g=a \end{gather+} (needs autonum)
223 \item multline, numbering always (and avoiding overfull hbox warning) \begin{multline+} m=u\line(1,0){220}=v \end{multline+} (needs autonum)
224 \item equation, numbering always \begin{equation+} e=q \end{equation+} (needs autonum)
225 }
226 \item align with line breaks with extra spacing
227 \begin{align}
228 a
229 \\[\baselineskip]
230 b
231 \end{align}
232 \ifautonum{
233 \item shortcut and split \ref{split} \[ \label{split}\begin{split} s \\ p \end{split} \] (needs autonum)
234 }
235 \item equation and split \ref{splitEquation} \begin{equation} \label{splitEquation}\begin{split} s \\ p \end{split} \end{equation}
236 \item align and split with the label defined before the split environment \ref{splitAlign}
237 \begin{align}
238 \label{splitAlign}
239 \begin{split}
240 s
241 \end{split}
242 \end{align}
243 \makeatletter
244 \ifdef{\autonum@currentLabel}{TEST FEHLGESCHLAGEN!}{}
245 \makeatother
246 \item align and split with the label defined in the split environment \ref{splitInAlign}
247 \begin{align}
248 \begin{split}
249 s\label{splitInAlign}
250 \end{split}
251 \end{align}
252 \item Align with split and non-split (should have two lines)
253 \begin{align}
254 \begin{split}
255 \text{line 1}
256 \end{split}
257 \\
258 \text{line 2}
259 \end{align}
260 \item Align with non-split and split (should have two lines)
261 \begin{align}
262 \text{line 1}
263 \\
264 \begin{split}
265 \text{line 2}
266 \end{split}
267 \end{align}
268 \item Align with two splits (should have four lines), none referenced)
269 \begin{align}
270 \begin{split}
271 \text{line 1}
272 \\
273 \text{line 2}
274 \end{split}
275 \\
276 \begin{split}
277 \text{line 3}
278 \\
279 \text{line 4}
280 \end{split}
281 \end{align}
282 \item Align with two splits (should have four lines), both referenced \ref{firstSplit} and \ref{secondSplit})
283 \begin{align}
284 \label{firstSplit}
285 \begin{split}
286 \text{line 1}
287 \\
288 \text{line 2}
289 \end{split}
290 \\
291 \label{secondSplit}
292 \begin{split}
293 \text{line 3}
294 \\
295 \text{line 4}
296 \end{split}
297 \end{align}
298 \item Align with split and label at the wrong place should result in the detection of an error
299 {
300 % Redefine \PackageError in a TeX group so the redifinition does not scatter.
301 \def\PackageError#1#2#3{\\\text{Package error successfully detected.}}%
302 \begin{align}
303 \begin{split}
304 1 = 1
305 \end{split}
306 \label{problematicLabel}
307 \end{align}
308 }
309 % \item super-short \[\(a+b\\d+e\)\]
310 % \item Using aligned \ref{alignedOne}, \ref{alignedThree}
311 % \begin{equation}
312 % \begin{aligned}
313 % a\label{alignedOne}\\
314 % b\label{alignedTwo}\\
315 % c\label{alignedThree}
316 % \end{aligned}
317 % \end{equation}
318 % \item Using gathered \ref{gatheredOne}, \ref{gatheredThree}
319 % \begin{equation}
320 % \begin{gathered}
321 % a\label{gatheredOne}\\
322 % b\label{gatheredTwo}\\
323 % c\label{gatheredThree}
324 % \end{gathered}
325 % \end{equation}
326 % \item Placing no number in long equations
327 % \begin{equation}
328 % \sum\sum\sum\sum\sum\sum\sum\sum\sum\sum\sum\sum\sum\sum\sum\sum\sum\sum\sum a
329 % \end{equation}
330 \item Split with a long line and a \textbackslash\texttt{notag} after ending split has too much spacing below the environment, if the split environment is not patched:
331 \begin{equation}
332 \begin{split}
333 \sum_1^2 a &= 2a\\
334 &= \sum_3^4 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
335 \end{split}\notag
336 \end{equation}
337 \item Split with a long line and a \textbackslash\texttt{notag} before ending split has correct spacing below the environment:
338 \begin{equation}
339 \begin{split}
340 \sum_1^2 a &= 2a\\
341 &= \sum_3^4 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\notag
342 \end{split}
343 \end{equation}
344 \item Split with a long line and without an explicit \textbackslash\texttt{notag} should have the same spacing as directly above and not the spacing as directly below:
345 \begin{equation}
346 \begin{split}
347 \sum_1^2 a &= 2a\\
348 &= \sum_3^4 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
349 \end{split}
350 \end{equation}
351 \item Split with a long line should have long spacing below the environment if it is referenced \ref{splitLong}:
352 \begin{equation}\label{splitLong}
353 \begin{split}
354 \sum_1^2 a &= 2a\\
355 &= \sum_3^4 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
356 \end{split}
357 \end{equation}
358 Note, that the \textbackslash\texttt{label} must not be put inside the \texttt{split} environment, as according to the \AmS-math documentation \texttt{split} provides no numbering.
359 \item Split inside an equation, where the label is inside split (which is discouraged, see directly above) and reference \ref{insideSplit}
360 \begin{equation}
361 \begin{split}
362 \label{insideSplit}
363 \text{Check this line for an equation number!}
364 \end{split}
365 \end{equation}
366 \item This is a reference to an align environment with alignment \ref{alignment}.
367 \begin{align}%
368 a &= 1,\label{alignment}\\%
369 cd &= 2\label{rowTwo}%
370 \end{align}%
371 \item This is an align environment with alignment and no text before the equation sign (there once was an error with the optional argument handling of the newline command).
372 \begin{align}
373 a &= 1,\label{eq:a}\\
374 &= 2\label{eq:b}
375 \end{align}
376 \end{itemize}
377 \section{Using ref in section \ref{i1}}\label{i1} text
378 \ifcleveref{
379 % \cref with hyperref makes problems inside of \section: http://tex.stackexchange.com/a/138950. This seems to be unknown for cleveref's author according to 14.2 in cleveref's documentation. If it would be possible to detect that we are inside a moving argument, there could be an automatic solution.
380 \section{Using cref in \texorpdfstring{\cref{i2}}{Section \ref{i2}}}\label{i2} text
381 \begin{figure}
382 \caption{Ref 2: \cref{i2} and \ref{i2}}
383 \end{figure}
384 }
385 \tableofcontents
386 \listoffigures
387 \end{document}