Debian Codegraph @

texmf-dist/source/latex/spacingtricks/spacingtricks.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2019-2023 by Antoine Missier <[email protected]>
4 %
5 % This file may be distributed and/or modified under the conditions of
6 % the LaTeX Project Public License, either version 1.3 of this license
7 % or (at your option) any later version. The latest version of this
8 % license is in:
9 %
10 % http://www.latex-project.org/lppl.txt
11 %
12 % and version 1.3 or later is part of all distributions of LaTeX version
13 % 2005/12/01 or later.
14 % \fi
15 %
16 % \iffalse
17 %<*driver>
18 \ProvidesFile{spacingtricks.dtx}
19 %</driver>
20 %<*package>
21 \NeedsTeXFormat{LaTeX2e}[2005/12/01]
22 \ProvidesPackage{spacingtricks}
23 [2023/12/06 v1.8 .dtx spacingtricks file]
24 %</package>
25 %<*driver>
26 \documentclass{ltxdoc}
27 \usepackage[utf8]{inputenc}
28 \usepackage[T1]{fontenc}
29 \usepackage[english]{babel}
30 \usepackage{mathptmx}
31 \usepackage[pifont]{spacingtricks}
32 \usepackage{amsmath}
33 \usepackage{tikz}
34 \usepackage{sectsty}
35 \usepackage{xcolor}
36
37 \definecolor{darkbrown}{rgb}{0.5,0.1,0.1}
38 \allsectionsfont{\color{darkbrown}}
39 \DisableCrossrefs
40 %\CodelineIndex
41 %\RecordChanges
42 \usepackage{hyperref}
43 \hypersetup{%
44 colorlinks,
45 linkcolor=blue, %red by default
46 citecolor=red, %green by default
47 pdftitle={spacingtricks},
48 pdfsubject={LaTeX package},
49 pdfauthor={Antoine Missier}
50 }
51 \begin{document}
52 \DeleteShortVerb{\|}
53 \MakeShortVerb{\"}
54 \DocInput{spacingtricks.dtx}
55 %\PrintChanges
56 %\PrintIndex
57 \end{document}
58 %</driver>
59 % \fi
60 %
61 % \CheckSum{261}
62 %
63 % \CharacterTable
64 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
65 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
66 % Digits \0\1\2\3\4\5\6\7\8\9
67 % Exclamation \! Double quote \" Hash (number) \#
68 % Dollar \$ Percent \% Ampersand \&
69 % Acute accent \' Left paren \( Right paren \)
70 % Asterisk \* Plus \+ Comma \,
71 % Minus \- Point \. Solidus \/
72 % Colon \: Semicolon \; Less than \<
73 % Equals \= Greater than \> Question mark \?
74 % Commercial at \@ Left bracket \[ Backslash \\
75 % Right bracket \] Circumflex \^ Underscore \_
76 % Grave accent \` Left brace \{ Vertical bar \|
77 % Right brace \} Tilde \~}
78 %
79 %
80 % \changes{v0.1}{2011/12/27}{Initial version}
81 % \changes{v1.0}{2019/05/04}{dtx and ins files, adding the footnote command}
82 % \changes{v1.0}{2019/06/16}{English translation of the documentation}
83 %
84 % \changes{v1.1}{2019/09/06}{
85 % - No automatic line breaking at the end of the centered command,
86 % - new length compactitemlist}
87 %
88 % \changes{v1.2}{2019/09/09}{
89 % - A bug correction in the last update}
90 %
91 % \changes{v1.3}{2020/11/02}{
92 % - Loading the setspace package,
93 % - small changes in compactlist environment,
94 % - improvement in dualboxes macro}
95 %
96 % \changes{v1.4}{2021/09/21}{
97 % - A mistake in the documentation is now corrected}
98 %
99 % \changes{v1.5}{2023/02/23}{
100 % - Changing font to times (with the mathptmx package),
101 % - changing pstricks figure to tikz to avoid double compilation,
102 % - tests and comments about wrapfig and picinpar packages}
103 % \changes{v1.5}{2023/02/25}{
104 % - adding the centeredline package,
105 % - adding the pifont package as option,
106 % - taking over the juxtapose environment from Christian Obrecht,
107 % - topsep of indentblock environment reduced to zero}
108 % \changes{v1.5}{2023/02/26}{
109 % - Tests and comments about paracol and reledpar packages}
110 %
111 % \changes{v1.6}{2023/03/05}{
112 % - Any list symbol is followed by a space if there is no punctuation character after it,
113 % - some changes in documentation}
114 %
115 % \changes{v1.7}{2023/07/27}{
116 % - Minor adjustments in the documentation}
117
118 % \changes{v1.8}{2023/12/05}{
119 % - New macro cstrut}
120 %
121 % \GetFileInfo{spacingtricks.sty}
122 %
123 % \title{The \textsf{spacingtricks} package\thanks{This document
124 % corresponds to \textsf{spacingtricks}~\fileversion, dated \filedate.}}
125 % \author{Antoine Missier \\ \texttt{[email protected]}}
126 % \date{December 6, 2023}
127 % \maketitle
128 %
129 % \section{Introduction}
130 %
131 % This package offers several macros to address spacing issues:
132 % \begin{compactlist}
133 % \item \hyperlink{centered}{\texttt{\bslash centered}} offers horizontal
134 % centering without introducing vertical spacing.
135 % \item \hyperlink{footnote}{\texttt{\bslash footnote}} has been redefined
136 % to avoid unsuitable spacing in certain cases.
137 % \item \hyperlink{vstrut}{\texttt{\bslash vstrut}} generates a strut
138 % with variable height or depth for maintaining consistent vertical spacing,
139 % and \hyperlink{cstrut}{\texttt{\bslash cstrut}} being symmetric around the mathematical axis.
140 % \item \hyperlink{indent}{\texttt{\bslash indent}} has been redefined
141 % to indent a line at the beginning
142 % of a particular paragraph even if "\parindent" has been set to 0.
143 % \item The \hyperlink{indentblock}{\texttt{indentblock}} environment
144 % allows indentation of all its content.
145 % \item The \hyperlink{compactlist}{\texttt{compactlist}} environment
146 % creates a compact list, as shown here, without vertical spacing between items.
147 % Additionally, aliases are provided for shorter
148 % \hyperlink{symbols}{list symbols}:
149 % "\bul", "\dash", "\ddash", "\aster", "\hand", "\checksymb", "\arrowsymb".
150 % \item Common abbreviations, \hyperlink{ie-eg}{\ie and \eg},
151 % are typeset using the macros "\ie" and "\eg" ensuring correct spacing.
152 % \item The \hyperlink{dualboxes}{\texttt{\bslash dualboxes}} command facilitates placing
153 % two boxes (figures, tables, text) side by side by adjusting the vertical positioning.
154 % \end{compactlist}
155 %
156 % \medskip
157 % Three other ``spacing'' packages are loaded by \textsf{spacingtricks}:
158 % \hyperlink{setspace}{\textsf{setspace}}~\cite{SETSP} (natively in \LaTeXe),
159 % used for setting line spacing in a piece of text,
160 % \textsf{xspace}~\cite{XSP}, which adds an inter-word space unless the macro
161 % is followed by a punctuation character,
162 % and \hyperlink{centeredline}{\textsf{centeredline}}~\cite{CENTER}
163 % which offers an interesting alternative
164 % to our "\centered" macro (see further).
165 % We also took over the fine \hyperlink{juxtapose}{\texttt{juxtapose}} environment
166 % from the \textsf{mafr}~\cite{MAFR}
167 % distribution, as another way to place boxes side by side.
168 %
169 % Furthermore, we have developed the package \textsf{arraycols}~\cite{ARCOL},
170 % which allows for effective management of spacing in \texttt{tabular}
171 % or \texttt{array} environments,
172 % and \textsf{mismath}~\cite{MSMATH} providing several macros to improve spacing
173 % in mathematical formulas.
174 %
175 % \section{Usage}
176 %
177 % \hypertarget{centered}{}
178 % \DescribeMacro{\centered}
179 % The "\centered"\marg{text} command yields a centered line without vertical spacing.
180 % It functions similarly to "\centerline", except in lists or tables where its behavior
181 % is notably improved (see the following examples).
182 % Additionally, the line break before (but not after) the macro is applied automatically.
183 %
184 % Here is a comparative example of the centering commands inside a list:
185 % \begin{enumerate}
186 % \item Here is a centered line using "\centered":
187 % \centered{Lorem ipsum dolor sit amet, consectetuer adipiscing elit.}
188 % \item Here is another centered line using "\\ \centerline":\\
189 % \centerline{Lorem ipsum dolor sit amet, consectetuer adipiscing elit.}
190 % \item Here is another centered line using "\par\centerline":
191 % \par\centerline{Lorem ipsum dolor sit amet, consectetuer adipiscing elit.}
192 % \item Here is a centered line using the \texttt{center} environment:
193 % \begin{center} Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \end{center}
194 % \end{enumerate}
195 %
196 % After using "\centered{...}", the end of line must be explicit,
197 % otherwise "\centered" will not function correctly. You can use "\\",
198 % which is equivalent to "\linebreak", or you can use
199 % a blank line to begin a new paragraph (equivalent to "\par").
200 % In the former case, no vertical space
201 % is added after the centered line, while in the latter case, the vertical space
202 % following the centered line is slightly larger.
203 % In the example provided, the centered line comes to an end, without line breaking
204 % because of the next "\item" command, and the vertical space is determined by the
205 % \texttt{enumerate} environment.
206 %
207 % \medskip
208 % In tables, "\centered" allows you to center a specific line in a cell independently of
209 % the column alignment
210 % \footnote{In tables, we can also utilize the powerful \texttt{\bslash makecell} command
211 % from the \textsf{makecell} package~\cite{MKCELL}. However,
212 % neither the \texttt{\bslash centerline} nor \texttt{\bslash centering} commands
213 % work for a single line in a cell.},
214 % Here's an example using "\begin{tabular}{|l|r|}":
215 %
216 % \begin{center}
217 % \begin{tabular}{|l|r|}
218 % \hline
219 % left-aligned content & right-aligned content \\
220 % \hline
221 % the second cell determines the width & \centered{another centered content} \\
222 % \hline
223 % \centered{a centered cell} & the last cell determines the width \\
224 % \hline
225 % \end{tabular}
226 % \end{center}
227 %
228 % \medskip
229 % \hypertarget{centeredline}{}
230 % \DescribeMacro{\centeredline}
231 % A limitation of our "\centered" macro is that it doesn't allow the use of
232 % \texttt{\bslash verb} commands inside its argument.
233 % However, you have the "\centeredline" command from the package
234 % \textsf{centeredline} by Jean-François Burnol~\cite{CENTER} to address this limitation.
235 % This small package is now loaded by \textsf{spacingtricks}.
236 % One other advantage of "\centeredline" is that it does not require an explicit
237 % end; the text can follow the command on the same line, and the line break will
238 % be automatic.
239 % Nevertheless, it doesn't work in tables (like in the example above),
240 % except when used with the \texttt{p} column declaration.
241 %
242 % \hypertarget{setspace}{}
243 % \medskip
244 % \DescribeEnv{onehalfspace}\DescribeEnv{doublespace}\DescribeEnv{spacing}
245 % \begin{onehalfspace}
246 % The \textsf{setspace} package~\cite{SETSP}, which is loaded by \textsf{spacingtricks},
247 % provides environments for changing the spacing between lines.
248 % The current paragraph is nested in a \texttt{onhalfspace} environment, as you can see.
249 % The \texttt{spacing} environment can be used to achieve other interline spacing,
250 % for example "\begin{spacing}{2.5}".
251 % \end{onehalfspace}
252 %
253 % \hypertarget{footnote}{}
254 % \medskip
255 % \DescribeMacro{\footnote}
256 % The "\footnote" command doesn't handle spacing issues well,
257 % especially when the \textsf{hyperref} package has been loaded.
258 % In English tradition, there is no space before numbers (or symbols) of note calls,
259 % and similarly at the beginning of footnotes,
260 % the text begins immediately after the note number
261 % \footnote{The typesetting of footnotes and note calls depends on national typographic
262 % rules which are, in principle, managed by the \textsf{babel} package.
263 % For instance, when activating the \texttt{french} option of \textsf{babel},
264 % a thin space is added before the note calls, and the new \texttt{\bslash footnote}
265 % macro does not alter this behavior.}.
266 % To avoid undesirable spaces, you don't have to leave any space before
267 % writing "\footnote{", for instance:
268 % \centeredline{
269 % "There is no space here\footnote{The old command} before the macro."
270 % }
271 % However, it may be convenient to place the "\footnote" command
272 % on a new line. To achieve this, "\footnote" has been redefined to completely eliminate
273 % unwanted spaces
274 % \footnote{Indeed, recommending the use of the \% symbol at the end of a line would suffice
275 % (but not in dtx files);
276 % its effect is to cancel the space produced by a line break,
277 % but it's not always something that comes to mind immediately.
278 % Furthermore let's note that our definition of \texttt{\bslash footnote} will have no effect
279 % when using the \texttt{\bslash VerbatimFootnotes} command from the \textsf{fancyvrb} package
280 % by Timothy Van Zandt~\cite{FVERB}.}.
281 %
282 % \medskip
283 % \noindent\begin{minipage}{5.6cm}
284 % \begin{verbatim}
285 %This is a note
286 %\footnote{
287 %The old command.}
288 %with bad spacing.
289 % \end{verbatim}
290 % \vspace{-4ex}
291 % This is a note
292 % \footnt{
293 % The old command.}
294 % with bad spacing.
295 % \end{minipage}
296 % \hfill
297 % \begin{minipage}{5.6cm}
298 % \begin{verbatim}
299 %This is a note
300 %\footnote{
301 %The new command.}
302 %with good spacing.
303 % \end{verbatim}
304 % \vspace{-4ex}
305 % This is a note
306 % \footnote{
307 % The new command.}
308 % with good spacing.
309 % \end{minipage}
310 %
311 % \medskip
312 % \DescribeMacro{\footnotespace} \DescribeMacro{\footenoteindent}
313 % Like the old "\footnote" command, the new one can take also
314 % an optional argument to force the number of the note.
315 % Additionally, we have always had customization macros such as
316 % "\footnotesize", "\footnotesep", "\footnoterule".
317 % However, two new macros have been added to manage spacing:
318 % "\footnotespace" which produces the space before the note call symbol,
319 % and "\footnoteindent" which produces the space at the beginning of the footnote text.
320 % For instance, with "\renewcommand{\footnotespace}{\,}" \\
321 % and "\renewcommand{\footnoteindent}{\enskip}"
322 % \footnote{\texttt{\bslash enskip} is equivalent to \texttt{\bslash hspace\{0.5em\}}.}
323 % we get:
324 %
325 % \begin{center}
326 % \renewcommand{\footnotespace}{\,}
327 % \renewcommand{\footnoteindent}{\enskip}
328 % \begin{minipage}{7cm}
329 % This is a note \footnote{en dash spacing at the beginning of the note.}
330 % with particular space settings.
331 % \end{minipage}
332 % \end{center}
333 %
334 % \hypertarget{vstrut}{}
335 % \DescribeMacro{\vstrut}
336 % The command "\vstrut"\oarg{depth}\marg{height} produces a strut with a
337 % variable height or depth,
338 % allowing you to increase the line's height above the baseline or its depth
339 % below (optional).
340 % This command can be used in various contexts, such as a text line, a table,
341 % a list, a formula, and more.
342 % If the values of \meta{height} and \meta{depth} are smaller than the height and depth
343 % of the current line, the command has no effect.
344 % Here are some examples:
345 %
346 % \begin{juxtapose}
347 % \begin{verbatim}
348 %\[\frac{\sqrt{0.5p}}{10}
349 % = \frac{\sqrt{\vstrut{1.7ex} 0.5p}}{10}\]
350 % \end{verbatim}
351 % \otherside
352 % \[\frac{\sqrt{0.5p}}{10} = \frac{\sqrt{\vstrut{1.7ex} 0.5p}}{10}\]
353 % \end{juxtapose}
354 % \vspace{-2ex}
355 % \noindent"\fbox{\vstrut{2ex}$\sigma(X)=1$}" gives
356 % \fbox{\vstrut{2ex}$\sigma(X)=1$}
357 % better than \fbox{$\sigma(X)=1$}.
358 %
359 % % \hypertarget{cstrut}{}
360 % \medskip
361 % \DescribeMacro{\cstrut}
362 % The "\cstrut" macro is a alternative of "\vstrut" that adds a symmetric strut in height
363 % and depth relative to the mathematical center line, which is halfway the height of an `x'.
364 % It takes a single parameter "\cstrut"\marg{height}.
365 % It's useful in \texttt{array} environments as it maintains
366 % the mathematical axis at the center of the cell with \meta{height}
367 % above and under.
368 %
369 % In a table, using
370 % "\renewcommand{\arraystretch}"\marg{stretch}
371 % allows you to increase the height of all rows, but it
372 % has a global effect, whereas "\cstrut" (or "\vstrut") allows to adjust the height
373 % of each row individually, as in the following table:
374 % \[
375 % \begin{array}{|c|}
376 % \hline
377 % \text{bad}\\
378 % \hline
379 % \displaystyle \lim_{\substack{x \to 1\\x>1}} \ln\left(\dfrac{x^2}{x-1}\right) \\
380 % \hline
381 % \dfrac{a}{b} \\
382 % \hline
383 % \displaystyle \int_{1}^{X} \frac{1}{t}\, \mathrm{d}t \\
384 % \hline
385 % \end{array}
386 % \qquad
387 % \begin{array}{|c|c|}
388 % \hline
389 % \multicolumn{2}{|c|}{\text{good}}\\
390 % \hline
391 % \displaystyle\lim_{\substack{x \to 1\\x>1}} \ln\left(\dfrac{x^2}{x-1}\right)\cstrut{3.8ex}
392 % & \mbox{obtained with } "\cstrut{3.8ex}" \\
393 % \hline
394 % \dfrac{a}{b} \cstrut{2.5ex} & "\cstrut{2.5ex}" \\
395 % \hline
396 % \displaystyle\int_{1}^{X} \frac{1}{t} \, \mathrm{d} t \vstrut[2.5ex]{4.2ex}
397 % & "\vstrut[2.5ex]{4.2ex}" \\
398 % \hline
399 % \end{array}
400 %\]
401 % However, for tables, we have the \textsf{arraycols} package~\cite{ARCOL},
402 % which is based on \textsf{cellspace}~\cite{CELLSP} and it allows to automatically adjust
403 % row heights. Nevertheless, "\cstrut" and "\vstrut" can be useful for fine adjustments.
404 %
405 % \hypertarget{indent}{}
406 % \medskip
407 % \DescribeMacro{\indent}
408 % The command "\setlength{\parindent}{0cm}" eliminates
409 % indentation at the beginning of every paragraph.
410 % However, in this case, the "\indent" command does no longer works
411 % if you want to apply exceptional indentation to a specific paragraph.
412 % To address this issue, the initial length of "\parindent" is saved in "\parindentlength",
413 % \DescribeMacro{\parindentlength}
414 % and the command "\indent" is redefined to allow indentation
415 % of the length "\parindentlength".
416 %
417 % \hypertarget{indentblock}{}
418 % \medskip
419 % \DescribeEnv{indentblock}
420 % The \texttt{indentblock} environment facilitates the indentation of an entire block of lines.
421 % It has an optional argument which sets the length of indentation
422 % (by default it uses "\parindentlength").
423 % The lyrics below have been indented (and typeset in italic shape) using
424 % "\begin{indentblock}\itshape" and stanzas 2 and 4 have undergone
425 % additional indentation using "\begin{indentblock}[3em]".
426 %
427 % \smallskip
428 % \begin{indentblock}\itshape
429 % Overhead the albatross hangs motionless upon the air \\
430 % And deep beneath the rolling waves in labyrinths of coral caves \\
431 % The echo of a distant time comes willowing across the sand \\
432 % And everything is green and submarine
433 % \begin{indentblock}[3em]
434 % And no one showed us to the land \\
435 % And no one knows the where's or why's \\
436 % But something stirs and something tries \\
437 % Starts to climb towards the light
438 % \end{indentblock}
439 % \noindent
440 % Strangers passing in the street \\
441 % By chance two separate glances meet \\
442 % And I am you and what I see is me \\
443 % And do I take you by the hand \\
444 % And lead you through the land \\
445 % And help me understand the best I can?
446 % \begin{indentblock}[3em]
447 % And no one calls us to move on \\
448 % And no one forces down our eyes \\
449 % No one speaks and no one tries \\
450 % No one flies around the sun
451 % \end{indentblock}
452 % \end{indentblock}
453 %
454 % \hypertarget{compactlist}{}
455 % \DescribeEnv{compactlist}
456 % As the name suggests, the "compactlist" environment allows you to create
457 % a ``compact'' list, meaning it has no vertical space above or between items.
458 % Similar to regular lists in \LaTeX, items are generated using the "\item" command.
459 % The environment also accepts an optional argument: "\begin{compactlist}"\oarg{symbol}.
460 %
461 % \hypertarget{symbols}{}
462 % \medskip
463 % \DescribeMacro{\bul}\DescribeMacro{\dash}\DescribeMacro{\ddash}\DescribeMacro{\aster}
464 % The default item symbol in the compactlist environment is "\textbullet",
465 % but it can be changed.
466 % We have provided aliases for several symbols commonly used in lists:
467 % "\bul" \bul\ (alias for "\textbullet"), "\dash" \dash\ (alias for "\textendash"),
468 % "\ddash" \ddash\ (alias for "\textemdash"),
469 % "\aster" \aster\ ("alias for \textasteriskcentered").
470 %
471 % \smallskip
472 % \DescribeEnv{[pifont]}
473 % \DescribeMacro{\hand}\DescribeMacro{\checksymb}\DescribeMacro{\arrowsymb}
474 % Some other common symbols can be found in the \textsf{pifont} package~\cite{PIFONT}.
475 % Therefore the \textsf{spacingtricks} package includess a \texttt{pifont} option
476 % that loads this package and creates the appropriate aliases:
477 % "\hand" \hand for "\ding{43}", "\checksymb" \checksymb for "\ding{51}"
478 % and "\arrowsymb" \arrowsymb for "\ding{226}".
479 %
480 % \medskip \noindent
481 % The following example is produced by "\begin{compactlist}[\checksymb]":
482 % \begin{compactlist}[\checksymb]
483 % \item First item.
484 % \item Second item.
485 % \item Third item.
486 % \end{compactlist}
487 % \hand These aliases can also be used directly in some text.
488 % The symbol is followed by a space if there is no punctuation character
489 % immediately after it (thanks to the
490 % macro \texttt{xspace} from the \textsf{xspace} package~\cite{XSP}).
491 % Use "\"\meta{symbol}"\unskip" if you want to remove this space.
492 %
493 % \smallskip
494 % \DescribeMacro{\compactlistindent}
495 % Indentation length is set by "\compactlistindent" (fixed at 0.5\,em by default)
496 % and can be modified with "\setlength".
497 % Notice that that there are several other ways to create a compact list,
498 % particularly by using the \texttt{noitemsep} key of the \textsf{enumitem} package~\cite{ENUM}.
499 %
500 % \medskip
501 % \DescribeEnv{dinglist}
502 % The \textsf{pifont} package has also a list environment "\begin{dinglist}"\marg{number}
503 % to typeset a list with normal spacing, using the "\ding"\marg{number} symbol
504 % for each "\item" (instead of using "\item[\ding"\marg{number}"]").
505 % So "\begin{dinglist}{226}" yields:
506 % \begin{dinglist}{51}
507 % \item The first item in the list.
508 % \item The second item in the list.
509 % \item The third item in the list.
510 % \end{dinglist}
511 %
512 % \hypertarget{ie-eg}{}
513 % \medskip
514 % \DescribeMacro{\ie} \DescribeMacro{\eg}
515 % In English, at the end of a sentence, the period is followed by an em space
516 % which is larger than an inter-word space.
517 % To achieve correct spacing after the abbreviations `\ie' (\textit{id est}) and `\eg'
518 % (\textit{exempli gratia}), \eg here, we provide the "\ie" and "\eg" macros,
519 % suggested in The \LaTeX\ Companion \cite{COMP}.
520 % In American typography, a comma is often placed after these abbreviations,
521 % which can be achieved using "\ie,"
522 % on the other hand, some authors prefer to typeset \textit{\ie} in italic shape,
523 % which is always possible with "\textit{\ie}".
524 %
525 % \hypertarget{dualboxes}{}
526 % \medskip
527 % \DescribeMacro{\dualboxes}
528 % Several packages aim to typeset text around a figure or a table,
529 % but some of them require providing the width of the box containing the figure or the table.
530 % Here we provide another approach with the macro
531 % "\dualboxes"\oarg{pos}\marg{left}\marg{right},
532 % which places two boxes, \meta{left} and \meta{right}, side by side.
533 % These boxes can contain figures, tables, a small line of text,
534 % parbox text, \texttt{minipage} environments
535 % (for several paragraphs and lists), etc.
536 % The optional \meta{pos} parameter sets the vertical level on which the boxes are aligned,
537 % and it takes a value between 0 (bottom) and 1 (top, default value).
538 %
539 % Here is a first example in which we have adjusted the position
540 % of the boxes vertically using "\dualboxes[0.6]".
541 %
542 % \def\myfigure{%
543 % \begin{tikzpicture}[scale=0.6]\tiny
544 % \draw[->] (-4.5,0) -- (4.5,0);
545 % \draw[->] (0,-2) -- (0,1.5);
546 % \foreach \x in {-4,...,4} {\draw (\x,0.1cm) -- (\x,-0.1cm) node[below] {$\x$};}
547 % \foreach \y in {-1,1} {\draw (0.1cm,\y) -- (-0.1cm,\y) node[left] {$\y$};}
548 % \draw[domain=-4.5:4.5,samples=100,color=red] plot ({\x},{2*\x/(exp(\x)-\x)});
549 % \end{tikzpicture}}
550 %
551 % \def\mytable{
552 % $\begin{array}{|*{6}{c|}} \hline
553 % x & -2 & -1 & 0 & 1 & 2 \\ \hline
554 % f(x) & -1,87 & -1,46 & 0 & 1,16 & 0,74 \\ \hline
555 % \end{array}$
556 % }
557 %
558 % \medskip
559 % \dualboxes[0.6]{\scriptsize \mytable}{\myfigure}
560 %
561 % \noindent
562 % The horizontal space is equally shared between left margin, inter-box space,
563 % and right margin.
564 %
565 % \medskip
566 % In the following example, boxes are aligned by top, and
567 % the right box has been shifted back (left) from 3\,cm
568 % to create an overlapping effect with the left one,
569 % which cannot be achieved using \textsf{picins}.
570 %
571 % \dualboxes{\scriptsize \mytable}{\mbox{} \hspace{-3cm} \myfigure}
572 % \begin{verbatim}
573 % \dualboxes{\scriptsize
574 % $\begin{array}{|*{6}{c|}} \hline
575 % x & -2 & -1 & 0 & 1 & 2 \\ \hline
576 % f(x) & -1,87 & -1,46 & 0 & 1,16 & 0,74 \\ \hline
577 % \end{array}$
578 % }{\mbox{} \hspace{-3cm}
579 % \begin{tikzpicture}[scale=0.6]\tiny
580 % \draw[->] (-4.5,0) -- (4.5,0);
581 % \draw[->] (0,-2) -- (0,1.5);
582 % \foreach \x in {-4,...,4} {
583 % \draw (\x,0.1cm) -- (\x,-0.1cm) node[below] {$\x$};}
584 % \foreach \y in {-1,1} {
585 % \draw (0.1cm,\y) -- (-0.1cm,\y) node[left] {$\y$};}
586 % \draw[domain=-4.5:4.5,samples=100,color=red]
587 % plot ({\x},{2*\x/(exp(\x)-\x)});
588 % \end{tikzpicture}
589 % }
590 % \end{verbatim}
591 %
592 % \DescribeMacro{\dualboxes*}
593 % Indeed this command has a starred version that eliminates space before the first box
594 % and after the second one, but not between them:
595 % "\dualboxes*"\oarg{pos}\marg{left}\marg{right}.
596 %
597 % \smallskip
598 % \dualboxes*[0.6]{\parbox{6.5cm}{
599 % In practice, the \texttt{\bslash dualboxes} macro is suitable for boxes in which
600 % you put figures, tables, or small one-line text.
601 % However, for longer text, it must be nested in a paragraph box, \eg
602 % here we used \texttt{\bslash parbox\{6.5cm\}\{...\}}.
603 % If you need to include several paragraphs, a list, or a mathematical displayed formula,
604 % you should use a \texttt{minipage} environment.}
605 % }{\myfigure}
606 %
607 % \medskip
608 % Let us mention that, unfortunately, it is not possible to use \texttt{verbatim} environments
609 % (nor the in-line \texttt{\bslash verb} command)
610 % within the "\dualboxes" arguments.
611 % Additionally, using footnotes or margin notes within "\dualboxes" is also not possible.
612 %
613 % \medskip
614 % For arranging two figures side by side, or a table and a figure, "\dualboxes" is perfect.
615 % However, for wrapping text around a figure, some other package may be more efficient.
616 % Les us first mention \textsf{wrapfig}~\cite{WRAPFIG}, one of the easiest, but
617 % it requires the text to be contained in a single paragraph (like above), without list.
618 % Otherwise you have to place it in a \texttt{minipage} environment.
619 %
620 % More sophisticated is the \textsf{picins} package~\cite{PICINS},
621 % cited in The \LaTeX\ Companion~\cite{COMP}.
622 % Unlike most others, it can be used with lists;
623 % however vertical positioning can be tricky,
624 % and it is not included in common distributions \TeX{}\,Live or MiK\TeX.
625 % Another package worth mentioning is \textsf{picinpar}~\cite{PICINPAR}, in which
626 % text can begin after the first line and flow to both sides of the figure.
627 % It allows several paragraphs, but it does not support lists or verbatim text.
628 %
629 % \hypertarget{juxtapose}{}
630 % \medskip
631 % \DescribeEnv{juxtapose}
632 % As a very interesting alternative, we present the powerful \texttt{juxtapose} environment,
633 % originally written by Christian Obrecht in the \texttt{fiche.cls class} file,
634 % which is part of the \textsf{mafr} distribution~\cite{MAFR}.
635 % We have made small improvements, including ensuring proper functionality
636 % and allowing customization of certain lengths.
637 % \DescribeMacro{\juxtopskip}\DescribeMacro{\juxbottomskip}
638 % \DescribeMacro{\juxsepspace}
639 % By default, the top and bottom lengths are set to "\smallskipamount",
640 % and the separation space is set to 1.5\,em.
641 % If the default lengths do not fit well for spacing above or below the environment,
642 % you can add a "\bigskip" or a "\vspace"\marg{dimen} for example,
643 % or, as a last resort, you can redefine the lengths "\juxtopskip" and "\juxbottomskip".
644 % \begin{juxtapose}
645 % In this example the \texttt{juxtapose} environment begins here.
646 % It can handle various elements, including figures, tables, as well as:
647 % \begin{compactlist}
648 % \item verbatim text: "\mytestmacro",
649 % \item text with several paragraphs,
650 % \item lists, like here (a compact list),
651 % \item displayed mathematics as shown on the right side,
652 % \end{compactlist}
653 % without the need for \texttt{multipage} environments.
654
655 % The two boxes are aligned by their center, but
656 % unlike "\dualboxes", you cannot adjust vertical positioning directly.
657 % However, you can use "\vspace" inside a box to alter vertical positioning
658 % and achieve the desired layout.\smallskip
659 %
660 % \otherside
661 % \myfigure
662 % \[ f(x) = \frac{2x}{\mathrm{e}^x-x} \]
663 % This is the last line of the environment.
664 % \end{juxtapose}
665 %
666 % Here begins the following text. The syntax of \texttt{juxtapose} is simple:
667 % \begin{center}
668 % "\begin{juxtapose} ... \otherside ... \end{juxtapose}"
669 % \end{center}
670 % It has an optional argument "\begin{juxtapose}"\oarg{leftratio}
671 % where \meta{leftratio} is the width ratio of the left side relative to "\textwidth"
672 % (the default value is "0.5" which means "0.5\textwidth").
673 %
674 % Paragraphs are indented inside each side, except the first one.
675 % For a figure, there's no need to shift it to the right
676 % (from indent length) to prevent users from forgetting to use "\noindent"
677 % before the figure.
678 % If you still want to indent the first paragraph, you can use "\indent".
679 % For horizontal alignment inside a box, you can use "\centering" or "\flushright",
680 % particularly useful for figures.
681 % For a global indentation of the first (or the second) box, you
682 % enclose it in an \texttt{indentblock} environment, and will work perfectly.
683 %
684 % \medskip
685 % One may ask why not using multi-column environments instead.
686 % In the classic \textsf{multicol} environment, you cannot choose
687 % horizontally unbalanced
688 % columns, and you cannot control where to transition to the other column.
689 %
690 % Some packages improve \textsf{multicol}.
691 % For instance, \textsf{vwcol}~\cite{VWCOL} allows fixed column widths.
692 % However, it still has limitations, such as not accepting verbatim text
693 % and not handling lists and figures correctly (as \texttt{juxtapose} did it above).
694 %
695 % Let's mention \textsf{paracol}~\cite{PARA} and \textsf{reledpar}~\cite{RELP},
696 % both designed for typesetting two columns of text in parallel,
697 % making them useful for translation or critical editions of text.
698 % They work fine with lists, figures, verbatim text, footnotes and margin notes.
699 % However, achieving precise vertical positioning of two boxes
700 % is not straightforward.
701 % While they offer synchronization mechanisms, convenient for text, they may not be ideal
702 % for placing two figures side by side.
703 % Additionally, they are a bit over-sized for our specific need.
704 % For our purposes, \texttt{juxtapose} or "\dualboxes" may be more suitable options.
705 %
706 % \StopEventually{}
707 %
708 % \section{Implementation}
709 % \begin{macrocode}
710 \newif\ifspacingtricks@pifont
711 \DeclareOption{pifont}{\spacingtricks@pifonttrue}
712 \ProcessOptions \relax
713
714 \RequirePackage{ifthen}
715 \RequirePackage{calc}
716 \RequirePackage{setspace}
717 \RequirePackage{xspace}
718 \RequirePackage{centeredline}
719 \ifspacingtricks@pifont \RequirePackage{pifont} \fi
720
721 \newcommand*{\centered}[1]{{\setlength{\parskip}{0pt}\par\noindent\hfill
722 #1\hfill\mbox{}}}
723 % \end{macrocode}
724 % The double braces are necessary here to ensure that the "\parskip" modification applies
725 % locally within the command and not globally to the rest of the document.
726 % \smallskip
727 % \begin{macrocode}
728 \newcommand{\footnotespace}{}
729 \newcommand{\footnoteindent}{}
730 \let\footnt\footnote
731 \renewcommand{\footnote}[2][]{\unskip\footnotespace%
732 \ifthenelse{\equal{#1}{}}{
733 \unskip\footnt{\footnoteindent\ignorespaces #2}
734 }{
735 \unskip\footnt[#1]{\footnoteindent\ignorespaces #2}
736 }\unskip
737 }
738 % \end{macrocode}
739 % "\unskip" eliminates undesirable spaces before and "\ignorespaces" after.
740 % \smallskip
741 % \begin{macrocode}
742 \newlength{\strutheight}
743 \newcommand*{\vstrut}[2][0pt]{%
744 \setlength{\strutheight}{#2}%
745 \addtolength{\strutheight}{#1}%
746 \unskip%
747 \rule[-#1]{0pt}{\strutheight}%
748 \ignorespaces%
749 }
750
751 \newlength{\strutdepth}
752 \newcommand*{\cstrut}[1]{%
753 \setlength\strutdepth{#1}%
754 \setlength\strutheight{2\strutdepth}% total height
755 \addtolength{\strutdepth}{-0.5ex}%
756 \unskip%
757 \rule[-\strutdepth]{0pt}{\strutheight}%
758 \ignorespaces%
759 }
760
761 \newlength{\parindentlength}
762 \setlength{\parindentlength}{\parindent}
763 \renewcommand{\indent}{\hspace{\parindentlength}}
764
765 \newenvironment*{indentblock}[1][\parindentlength]{
766 \begin{list}{}{%
767 \setlength{\leftmargin}{#1}
768 \setlength{\itemsep}{0pt}
769 \setlength{\topsep}{0pt} % previously 1ex
770 \setlength{\partopsep}{0pt}
771 }
772 \item[]
773 }{\end{list}}
774
775 \newlength{\compactlistindent}
776 \setlength{\compactlistindent}{0.5em}
777 \newenvironment*{compactlist}[1][\textbullet]{
778 \par % sometimes necessary
779 \begin{list}{#1\unskip}{% \unskip gobbles space created by \xspace
780 \setlength{\itemsep}{0pt}
781 \setlength{\parsep}{0pt}
782 \setlength{\topsep}{0ex}
783 \setlength{\partopsep}{0pt}
784 \setlength{\labelwidth}{1em}
785 \setlength{\leftmargin}{\labelwidth}
786 \addtolength{\leftmargin}{\labelsep}
787 \addtolength{\leftmargin}{\compactlistindent}
788 }
789 }{\end{list}}
790
791 \providecommand{\bul}{\textbullet\xspace}
792 \providecommand{\dash}{\textendash\xspace}
793 \providecommand{\ddash}{\textemdash\xspace}
794 \providecommand{\aster}{\textasteriskcentered\xspace}
795 % \end{macrocode}
796 % The command "\asterisk" already exists in the \textsf{mathabx} package (for math mode only).\\
797 % The following macros require the \textsf{pifont} package.
798 % \smallskip
799 % \begin{macrocode}
800 \ifspacingtricks@pifont
801 \providecommand{\hand}{\ding{43}\xspace}
802 \providecommand{\checksymb}{\ding{51}\xspace}
803 \providecommand{\arrowsymb}{\ding{226}\xspace}
804 \fi
805
806 \providecommand{\ie}{i.e.\@\xspace}
807 \providecommand{\eg}{e.g.\@\xspace}
808
809 \newcommand{\@@dualboxes}[3][1]{
810 \par\noindent
811 \raisebox{\depth-#1\totalheight}{#2} \hfill % needs calc
812 \raisebox{\depth-#1\totalheight}{#3} \smallskip
813 }
814 \newcommand{\@dualboxes}[3][1]{
815 \par\noindent \hfill
816 \raisebox{\depth-#1\totalheight}{#2} \hfill
817 \raisebox{\depth-#1\totalheight}{#3} \hfill\mbox{}\smallskip
818 }
819 \newcommand{\dualboxes}{\@ifstar{\@@dualboxes}{\@dualboxes}}
820
821 % \end{macrocode}
822 %
823 % The following macro was found in the \texttt{fiche.cls} file,
824 % distributed with the \textsf{mafr} package by Christian Obrecht~\cite{MAFR}.
825 % It had some minor bugs in spacing.
826 % I made small changes, including the addition of lengths parameters and the "\linewidth"
827 % instruction (without which, lists in the first side would send the second side
828 % out of the page).
829 % \begin{macrocode}
830 \newlength\juxtopskip
831 \setlength\juxtopskip{\smallskipamount}
832 \newlength\juxbottomskip
833 \setlength\juxbottomskip{\smallskipamount}
834 \newlength\juxsepspace
835 \setlength\juxsepspace{1.5em}
836 \newlength\side@width
837
838 \newenvironment{juxtapose}[1][0.5]{% left side ratio
839 \def\otherside{\egroup % the internal function remembers \side@width
840 \@tempdima=\side@width
841 \side@width=\textwidth
842 \advance\side@width by -\@tempdima
843 \advance\side@width by -\juxsepspace
844 \hskip\juxsepspace
845 \linewidth=\side@width % for lists environments
846 \vcenter\bgroup\hsize=\side@width\noindent % \ignorespaces useless
847 }
848 \side@width=#1\textwidth
849 \advance\side@width by -0.5\juxsepspace
850 \linewidth=\side@width % for lists environments
851 \par\vskip\juxtopskip%
852 \hbox\bgroup\begin{math}
853 \vcenter\bgroup\hsize=\side@width\noindent\ignorespaces
854 }{\egroup\end{math}\egroup\vskip\juxbottomskip}
855
856 % \end{macrocode}
857 %
858 % \medskip
859 % \begin{thebibliography}{18}
860 % \begin{raggedright}
861 % \bibitem{SETSP} \emph{The \textsf{setspace} Package}, Robin Fairbairns, Geoffrey Tobin,
862 % CTAN, v9.7b 2022/12/04.
863 % \bibitem{XSP} \emph{The \textsf{xspace} package}, David Carlisle, Morten Høgholm,
864 % CTAN v1.13 2014/10/28.
865 % \bibitem{CENTER} \emph{\textsf{centeredline} -- A macro for centering lines}, Jean-François
866 % Burnol, CTAN, v1.2 2022/10/10.
867 % \bibitem{MAFR} \emph{La distribution \textsf{mafr}}, Christian Obrecht,
868 % CTAN, v1.0 17/09/2006.
869 % \bibitem{ARCOL} \emph{The \textsf{arraycols} package}, Antoine Missier, CTAN,
870 % v1.4 2031/09/13.
871 % \bibitem{MSMATH} \emph{\textsf{mismath} -- Miscellaneous mathematical macros},
872 % Antoine Missier, CTAN, v2.8 2023/07/27.
873 % \bibitem{FVERB} \emph{The \textsf{‘fancyvrb’} package -- Fancy Verbatims in \LaTeX},
874 % Timothy Van Zandt, CTAN, v4.5a 2023/01/19.
875 % \bibitem{MKCELL} \emph{The \textsf{makecell} package}, Olga Lapko, CTAN, v0.1e 2009/08/03.
876 % \bibitem{CELLSP} \emph{The \textsf{cellspace} package}, Josselin Noirel, CTAN,
877 % v1.9.0 2022/01/04.
878 % \bibitem{PIFONT} \emph{\textsf{pifont} -- Using common PostScript fonts with \LaTeX},
879 % Walter Schmidt, CTAN, v9.3 2020/03/25.
880 % \bibitem{ENUM} \emph{Customizing lists with the \textsf{enumitem} package}, Javier Bezos,
881 % CTAN, v3.9 2019/06/20.
882 % \bibitem{WRAPFIG} \emph{The \textsf{wrapfig} package}, Donald Arseneau, CTAN,
883 % v3.6 2003/01/31.
884 % \bibitem{PICINS} \emph{Bilder in \LaTeX -Dokumenten -- PicIns-Benutzerhandbuch},
885 % Joachim Bleser, Edmund Lang, CTAN, v3.0 sept. 1992.
886 % \bibitem{PICINPAR} \emph{The \textsf{picinpar} package}, Friedhelm Sowa, Stefan Blochwitz,
887 % CTAN, v1.3 2022/11/25.
888 % \bibitem{VWCOL} \emph{The \textsf{vwcol} package}, Will Robertson, CTAN, v0.2 2015/02/10.
889 % \bibitem{PARA} \emph{Package \textsf{paracol}: Yet Another Multi-Column Package
890 % to Typeset Columns in Parallel}, Hiroshi Nakashima, CTAN, v1.35 2018/12/31.
891 % \bibitem{RELP} \emph{Parallel typesetting for critical editions:
892 % the \textsf{reledpar} package}, Maïeul Rouquette, Peter Wilson, Herries Press, CTAN,
893 % 2.25.3 2022/04/22.
894 % \bibitem{COMP} \emph{The \LaTeX\ Companion}. Frank Mittelbach, Michel Goossens,
895 % Johannes Braams, David Carlisle, Chris Rowley, 2nd edition, Pearson Education, 2004.
896 % \end{raggedright}
897 % \end{thebibliography}
898 %
899 % \Finale
900 \endinput