Debian Codegraph @

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

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2017 Scott Pakin <[email protected]>
4 % ----------------------------------------------------
5 %
6 % This package may be distributed and/or modified under the
7 % conditions of the LaTeX Project Public License, either version 1.3c
8 % of this license or (at your option) any later version.
9 % The latest version of this license is in
10 % http://www.latex-project.org/lppl.txt
11 % and version 1.3c or later is part of all distributions of LaTeX
12 % version 2008/05/04 or later.
13 %
14 % \fi
15 %
16 % \iffalse
17 %<*driver>
18 \ProvidesFile{eqparbox.dtx}
19 %</driver>
20 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
21 %<package>\ProvidesPackage{eqparbox}
22 %<*package>
23 [2017/09/03 v4.1 Create equal-widthed boxes]
24 %</package>
25 %
26 %<*driver>
27 \documentclass{ltxdoc}
28 \usepackage{eqparbox}
29 \usepackage{calligra}
30 \usepackage{array}
31 \usepackage{boxedminipage}
32 \usepackage{needspace}
33 \usepackage{ifmtarg}
34 \usepackage[subrefformat=parens,labelformat=parens]{subfig}
35 \usepackage[bookmarksopen]{hyperref}
36 \EnableCrossrefs
37 \CodelineIndex
38 \RecordChanges
39
40 % Uncomment the following line if you don't want to include a
41 % source-code listing.
42 %\OnlyDescription
43
44 \begin{document}
45 \sloppy
46 \DocInput{eqparbox.dtx}
47 \Needspace{10\baselineskip}
48 \phantomsection\addcontentsline{toc}{section}{Change History}
49 \PrintChanges
50 \makeatletter
51 \let\orig@index@prologue=\index@prologue
52 \def\index@prologue{%
53 \phantomsection\addcontentsline{toc}{section}{Index}
54 \orig@index@prologue
55 }%
56 \makeatother
57 \Needspace{12\baselineskip}
58 \PrintIndex
59 \end{document}
60 %</driver>
61 % \fi
62 %
63 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 %
65 % \CheckSum{536}
66 %
67 % \CharacterTable
68 % {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
69 % 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
70 % Digits \0\1\2\3\4\5\6\7\8\9
71 % Exclamation \! Double quote \" Hash (number) \#
72 % Dollar \$ Percent \% Ampersand \&
73 % Acute accent \' Left paren \( Right paren \)
74 % Asterisk \* Plus \+ Comma \,
75 % Minus \- Point \. Solidus \/
76 % Colon \: Semicolon \; Less than \<
77 % Equals \= Greater than \> Question mark \?
78 % Commercial at \@ Left bracket \[ Backslash \\
79 % Right bracket \] Circumflex \^ Underscore \_
80 % Grave accent \` Left brace \{ Vertical bar \|
81 % Right brace \} Tilde \~}
82 %
83 % \changes{v1.0}{2001/04/19}{Initial version}
84 % \changes{v2.0}{2004/07/31}{Rewrote to use only two \meta{dimen}s total
85 % and the rest macros (problem reported by Gilles P\'erez-Lambert and
86 % Plamen Tanovski; solution suggested by David Kastrup and Donald
87 % Arseneau)}
88 %
89 % \GetFileInfo{eqparbox.dtx}
90 %
91 % \DoNotIndex{\@auxout,\@cons,\@ifnextchar,\@ifundefined,\@ne,\@tempboxa}
92 % \DoNotIndex{\@tempdima,\DeclareRobustCommand,\\,\advance,\begin}
93 % \DoNotIndex{\begingroup,\bgroup,\box,\csname,\def,\egroup,\else,\end}
94 % \DoNotIndex{\endcsname,\endgroup,\expandafter,\fi,\gdef,\global,\hbox}
95 % \DoNotIndex{\ifdim,\ifnum,\ifx,\immediate,\let,\long,\m@ne,\mbox}
96 % \DoNotIndex{\newcommand,\newdimen,\newif,\newlength,\noexpand,\relax}
97 % \DoNotIndex{\renewcommand,\renewenvironment,\romannumeral,\sbox,\setbox}
98 % \DoNotIndex{\space,\string,\the,\wd,\xdef,\z@}
99 %
100 % ^^A The following environment, which typesets a declaration of a command
101 % ^^A in a box set out into the margin, was copied almost verbatim from
102 % ^^A ltxguide.cls.
103 % \newenvironment{decl}[1][]^^A
104 % {\par\small\addvspace{4.5ex plus 1ex}^^A
105 % \vskip -\parskip
106 % \ifx\relax#1\relax
107 % \def\@decl@date{}^^A
108 % \else
109 % \def\@decl@date{\NEWfeature{#1}}^^A
110 % \fi
111 % \noindent\hspace{-\leftmargini}^^A
112 % \begin{tabular}{|l|}\hline\ignorespaces}^^A
113 % {\\\hline\end{tabular}\nobreak\@decl@date\par\nobreak
114 % \vspace{2.3ex}\vskip -\parskip}
115 %
116 % ^^A Define a style for typesetting package names.
117 % \DeclareRobustCommand{\pkgname}[1]{^^A
118 % \textsf{#1}\index{#1=\textsf{#1} (package)}}
119 %
120 % ^^A Give LaTeX some more leeway in placing floats
121 % ^^A (suggested by Donald Arseneau <[email protected]>).
122 % \renewcommand{\topfraction}{0.85}
123 % \renewcommand{\bottomfraction}{0.7}
124 % \renewcommand{\textfraction}{0.15}
125 % \renewcommand{\floatpagefraction}{0.66}
126 % \renewcommand{\dbltopfraction}{0.66}
127 % \renewcommand{\dblfloatpagefraction}{0.66}
128 % \setcounter{topnumber}{9}
129 % \setcounter{bottomnumber}{9}
130 % \setcounter{totalnumber}{20}
131 % \setcounter{dbltopnumber}{9}
132 %
133 % ^^A Because we put table captions *above* tables, we should add a
134 % ^^A little extra space between the caption and the table.
135 % \setlength{\belowcaptionskip}{2ex}
136 %
137 % ^^A Properly hyphenate Rob Verhoeven's name.
138 % \hyphenation{Ver-hoe-ven}
139 %
140 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
141 %
142 % \title{The \pkgname{eqparbox} package\thanks{This document
143 % corresponds to \pkgname{eqparbox}~\fileversion, dated \filedate.}}
144 % \author{Scott Pakin \\ \textit{[email protected]}}
145 % \hypersetup{^^A
146 % pdftitle={The eqparbox package},
147 % pdfauthor={Scott Pakin <[email protected]>},
148 % pdfsubject={LaTeX package for typesetting text in equal-widthed boxes},
149 % pdfkeywords={LaTeX2e, parbox, makebox, framebox, savebox, boxes, automatic width, largest}
150 % }
151 %
152 % \maketitle
153 %
154 % \begin{abstract}
155 % The \pkgname{eqparbox} package makes it easy to define a group of
156 % boxes (such as those produced by |\parbox| or |\makebox|) whose
157 % members all have the same width, the natural width of the widest
158 % member. A document can contain any number of groups, and each group
159 % can contain any number of members. This simple, equal-width
160 % mechanism can be used for a variety of alignment purposes, as is
161 % evidenced by the examples in this document.
162 % \end{abstract}
163 %
164 % \section{Motivation}
165 % \label{sec:motivation}
166 %
167 % Let's start with a little test. How would you typeset
168 % Figure~\ref{fig:quotations}, in which the names of the quotations'
169 % authors are left-justified relative to each other but as a group abut
170 % the right margin? And second, how would you typeset the r\'esum\'e
171 % excerpt shown in Figure~\ref{fig:resume-excerpt} while meeting the
172 % following requirements:
173 %
174 % \begin{enumerate}
175 % \item The header columns must be left-justified relative to each
176 % other.
177 % \item The header columns should be evenly spaced across the page.
178 % \item Page breaks should be allowed within the r\'esum\'e.
179 % \end{enumerate}
180 %
181 % \begin{figure}[htbp]
182 % \centering
183 % \makeatletter
184 % \newcommand{\showquote}[2]{^^A
185 % \begin{flushright}
186 % ---~\eqparbox{quotebox}{\sffamily#1}^^A
187 % \@ifnotmtarg{#2}{\\
188 % \mbox{}\phantom{---}~\eqparbox{quotebox}{\sffamily\itshape#2}^^A
189 % }^^A
190 % \end{flushright}^^A
191 % \par
192 % }
193 % \makeatother
194 % \begin{boxedminipage}{\linewidth}
195 % The only medicine for suffering, crime, and all other woes of mankind,
196 % is wisdom. Teach a man to read and write, and you have put into his
197 % hands the great keys of the wisdom box. But it is quite another thing
198 % to open the box.
199 % \showquote{Thomas Huxley}{}
200 %
201 % I would like a simple life \\
202 % yet all night I am laying \\
203 % poems away in a long box. \par
204 % \bigskip
205 % It is my immortality box, \\
206 % my lay-away plan, \\
207 % my coffin.
208 % \showquote{Anne Sexton}{The Ambition Bird}
209 %
210 % \bigskip
211 %
212 % We have four boxes with which to defend our freedom: the soap box, the
213 % ballot box, the jury box, and the cartridge box.
214 % \showquote{Larry McDonald}{}
215 %
216 % \bigskip
217 %
218 % I saw the Count lying within the box upon the earth, some of which the
219 % rude falling from the cart had scattered over him. He was deathly
220 % pale, just like a waxen image, and the red eyes glared with the
221 % horrible vindictive look which I knew so well.
222 % \showquote{Bram Stoker}{Dracula}
223 %
224 % \bigskip
225 %
226 % Life in a box is better than no life at all, I expect. You'd
227 % have a chance, at least. You could lie there thinking, ``Well,
228 % at least I'm not dead.''
229 % \showquote{Tom Stoppard}{Rosencrantz~\& Guildenstern Are Dead}
230 %
231 % \bigskip
232 %
233 % Alla fin del gioco tanto va nel sacco il re quanto la pedina. \\
234 % \textit{(After the game, the king and pawn go into the same box.)}
235 % \showquote{Italian proverb}{}
236 % \end{boxedminipage}
237 % \caption{Quotations with left-aligned attributions}
238 % \label{fig:quotations}
239 % \end{figure}
240 %
241 % \begin{figure}[htbp]
242 % \bigskip\noindent\rule{\linewidth}{1pt}\bigskip\par
243 % \noindent
244 % \eqparbox{place}{\textbf{Widgets, Inc.}} \hfill
245 % \eqparbox{title}{\textbf{Senior Widget Designer}} \hfill
246 % \eqparbox{dates}{\textbf{1/95--present}}
247 %
248 % \begin{itemize}
249 % \item Supervised the development of the new orange and blue widget lines.
250 % \item Improved the design of various widgets, making them less sticky
251 % and far less likely to explode.
252 % \item Made widget management ten times more cost-effective.
253 % \end{itemize}
254 %
255 % \noindent
256 % \eqparbox{place}{\textbf{Thingamabobs, Ltd.}} \hfill
257 % \eqparbox{title}{\textbf{Lead Engineer}} \hfill
258 % \eqparbox{dates}{\textbf{9/92--12/94}}
259 %
260 % \begin{itemize}
261 % \item Found a way to make thingamabobs run on solar power.
262 % \item Drafted a blueprint for a new doohickey-compatibility module for
263 % all cool-mint thingamabobs.
264 % \item Upgraded superthingamabob specification document from Microsoft
265 % Word to \LaTeXe.
266 % \end{itemize}
267 % \noindent\rule{\linewidth}{1pt}
268 % \caption{Excerpt from a sample r\'esum\'e}
269 % \label{fig:resume-excerpt}
270 % \end{figure}
271 %
272 % The two questions can be answered the same way: by putting various
273 % blocks of text into equal-widthed boxes. If the author names in
274 % Figure~\ref{fig:quotations} are placed within a |flushright|
275 % environment and in |\parbox|es as wide as the widest text
276 % (``Rosencrantz~\& Guildenstern Are Dead''), they will appear as
277 % desired. Similarly, if the company names in
278 % Figure~\ref{fig:resume-excerpt} are both put in a |\parbox| as wide as
279 % ``Thingamabobs, Ltd.,'' the job titles in a |\parbox| as wide as
280 % ``Senior Widget Designer,'' and the dates in a |\parbox| as wide as
281 % ``1/95--present,'' then they can be spaced evenly by separating them
282 % with |\hfill|s.
283 %
284 % The problem is in choosing the width for each set of |\parbox|es.
285 % Considering for now just Figure~\ref{fig:resume-excerpt}, the user
286 % must typeset the r\'esum\'e once to see which entry in each column is
287 % the widest and then assign lengths appropriately:
288 %
289 % \begin{verbatim}
290 % \newlength{\placewidth}
291 % \settowidth{\placewidth}{Thingamabobs, Ltd.} % Employment 2
292 % \newlength{\jobtitlewidth}
293 % \settowidth{\jobtitlewidth}{Senior Widget Designer} % Employment 1
294 % \newlength{\dateswidth}
295 % \settowidth{\dateswidth}{1/95--present} % Employment 1
296 % \end{verbatim}
297 %
298 % \noindent
299 % Every time a piece of information changes, it must be changed in two
300 % places: in the r\'esum\'e itself and in the |\settowidth|
301 % command. When employment information is added or deleted, the
302 % |\settowidth| commands must be modified to reflect the new
303 % maximum-widthed entry in each column. If only there were a simpler
304 % way to keep a set of |\parbox|es as wide as the widest entry in the
305 % set\,\dots
306 %
307 % That simpler way is the \pkgname{eqparbox} package.
308 % \pkgname{eqparbox} exports an |\eqparbox| macro that works just like
309 % |\parbox|, except that instead of specifying the width of the box, one
310 % specifies the group that the box belongs to. All boxes in the same
311 % group will be typeset as wide as the widest member of the group. In
312 % that sense, an |\eqparbox| behaves like a cell in an~|l|, |c|, or~|r|
313 % column in a |tabular|; |\eqparbox|es in the same group are analogous
314 % to cells in the same column. Unlike the cells in a |tabular| column,
315 % however, a group of |\eqparbox|es can be spread throughout the
316 % document.
317 %
318 % \section{Usage}
319 % \label{sec:usage}
320 %
321 % \begin{decl}
322 % |\eqparbox| \oarg{pos} \oarg{height} \oarg{inner-pos} \marg{tag} \marg{text} \\
323 % |\eqmakebox| \oarg{tag} \oarg{pos} \marg{text} \\
324 % |\eqframebox| \oarg{tag} \oarg{pos} \marg{text} \\
325 % |\eqsavebox| \marg{cmd} \oarg{tag} \oarg{pos} \marg{text} \\[1ex]
326 % |\begin{eqminipage}| \oarg{pos} \oarg{height} \oarg{inner-pos} \marg{tag} \\
327 % \quad \meta{text} \\
328 % |\end{eqminipage}|
329 % \end{decl}
330 %
331 % These are almost identical to, respectively, the |\parbox|,
332 % |\makebox|, |\framebox|, and |\savebox| macros and the |minipage|
333 % environment. The key difference is that the \meta{width} argument is
334 % replaced by a \meta{tag} argument. (For a description of the
335 % remaining arguments, look up |\parbox|, |\makebox|, |\framebox|,
336 % |\savebox|, and |minipage| in any \LaTeXe\ book or in the
337 % \texttt{usrguide.pdf} file that comes with all \TeX\ distributions.)
338 % \meta{tag} can be any valid identifier. All boxes produced using the
339 % same tag are typeset in a box wide enough to hold the widest of them.
340 % Discounting \TeX's limitations, any number of tags can be used in the
341 % same document, and any number of boxes can share a tag. The only
342 % catch is that \texttt{latex} will need to be run a second time for the
343 % various box widths to stabilize.
344 %
345 % \begin{decl}
346 % |\eqboxwidth| \marg{tag}
347 % \end{decl}
348 %
349 % It is sometimes useful to take the width of a box produced by one of
350 % the preceding commands. While the width can be determined by creating
351 % an |\eqparbox| and using |\settowidth| to measure it, the
352 % \pkgname{eqparbox} package defines a convenience routine called
353 % |\eqboxwidth| that achieves the same result.
354 %
355 % |\eqboxwidth| makes it easy to typeset something like
356 % Table~\ref{tbl:mixed-tabular}. Table~\ref{tbl:mixed-tabular}'s only
357 % column expands to fit the widest cell in the column, excluding the
358 % final cell. The final cell's text word-wraps within whatever space is
359 % allocated to it. In a sense, the first four cells behave as if they
360 % were typeset in an~|l| column, while the final cell behaves as if it
361 % were typeset in a~|p| column. In actuality, the column is an~|l|
362 % column; an |\eqparbox| for the first four cells ensures the column
363 % stretches appropriately while a |\parbox| of width
364 % |\eqboxwidth{|\meta{tag}|}| in the final cell ensures that the final
365 % cell word-wraps.
366 %
367 % Section~\ref{sec:tabular-l-p} presents a more general version of this
368 % approach that doesn't require cells to be divided explicitly into
369 % |\eqparbox| cells and |\parbox| cells.
370 %
371 % \begin{table}[htbp]
372 % \centering
373 % \caption{A \texttt{tabular} that stretches to fit some cells while
374 % forcing others to wrap}
375 % \label{tbl:mixed-tabular}
376 % \DeleteShortVerb{\|}
377 % \begin{tabular}{|@{}l@{}|}
378 % \hline
379 % \eqparbox[b]{wtab}{Wide} \\ \hline
380 % \eqparbox[b]{wtab}{Wider} \\ \hline
381 % \eqparbox[b]{wtab}{Wider than that} \\ \hline
382 % \eqparbox[b]{wtab}{This is a fairly wide cell} \\ \hline
383 % \parbox[b]{\eqboxwidth{wtab}}{\strut
384 % While this cell's text wraps, the previous cells (whose text
385 % doesn't wrap) determine the width of the column.} \\ \hline
386 % \end{tabular}
387 % \MakeShortVerb{\|}
388 % \end{table}
389 %
390 % \begin{decl}
391 % |\eqsetminwidth| \marg{tag} \marg{width} \\
392 % |\eqsetmaxwidth| \marg{tag} \marg{width}
393 % \end{decl}
394 %
395 % These macros override the width calculation for boxes associated with
396 % tag \meta{tag}, ensuring that they are no narrower than a given
397 % minimum (|\eqsetminwidth|) and no wider than a given maximum
398 % (|\eqsetmaxwidth|).
399 %
400 % \begin{decl}
401 % |\eqsetminwidthto| \marg{tag} \marg{text} \\
402 % |\eqsetmaxwidthto| \marg{tag} \marg{text}
403 % \end{decl}
404 %
405 % These macros are analogous to |\eqsetminwidth| and |\eqsetmaxwidth|
406 % but automatically compute the natural width of the given text and use
407 % that as the minimum (|\eqsetminwidthto|) or maximum
408 % (|\eqsetmaxwidthto|) width for boxes using tag \meta{tag}.
409 %
410 %
411 % \section{Examples}
412 % \label{sec:examples}
413 %
414 % This section presents some sample uses of the macros described in
415 % Section~\ref{sec:usage}.
416 %
417 % \subsection{Figures and tables from previous sections}
418 % \label{sec:prev-figs-tabs}
419 %
420 % Figure~\ref{fig:quotations} was typeset using an |\eqparbox|-based
421 % helper macro, |\showquote|:
422 %
423 % \begin{verbatim}
424 % \usepackage{ifmtarg}
425 % \makeatletter
426 % \newcommand{\showquote}[2]{%
427 % \begin{flushright}
428 % ---~\eqparbox{quotebox}{\sffamily#1}%
429 % \@ifnotmtarg{#2}{\\
430 % \mbox{}\phantom{---}~\eqparbox{quotebox}{\sffamily\itshape#2}%
431 % }%
432 % \end{flushright}%
433 % \par
434 % }
435 % \makeatother
436 % \end{verbatim}
437 % \centerline{$\vdots$}
438 % \begin{verbatim}
439 % Alla fin del gioco tanto va nel sacco il re quanto la pedina. \\
440 % \textit{(After the game, the king and pawn go into the same box.)}
441 % \showquote{Italian proverb}{}
442 % \end{verbatim}
443 %
444 % Figure~\ref{fig:resume-excerpt}'s headings were typeset with the
445 % following code:
446 %
447 % \begin{verbatim}
448 % \noindent
449 % \eqparbox{place}{\textbf{Widgets, Inc.}} \hfill
450 % \eqparbox{title}{\textbf{Senior Widget Designer}} \hfill
451 % \eqparbox{dates}{\textbf{1/95--present}}
452 % \end{verbatim}
453 % \centerline{$\vdots$}
454 % \begin{verbatim}
455 % \noindent
456 % \eqparbox{place}{\textbf{Thingamabobs, Ltd.}} \hfill
457 % \eqparbox{title}{\textbf{Lead Engineer}} \hfill
458 % \eqparbox{dates}{\textbf{9/92--12/94}}
459 % \end{verbatim}
460 % \centerline{$\vdots$}
461 % \bigskip
462 %
463 % Finally, Table~\ref{tbl:mixed-tabular} was typeset using the
464 % following code:
465 %
466 % \begin{verbatim}
467 % \begin{tabular}{|@{}l@{}|}
468 % \hline
469 % \eqparbox[b]{wtab}{Wide} \\ \hline
470 % \eqparbox[b]{wtab}{Wider} \\ \hline
471 % \eqparbox[b]{wtab}{Wider than that} \\ \hline
472 % \eqparbox[b]{wtab}{This is a fairly wide cell} \\ \hline
473 % \parbox[b]{\eqboxwidth{wtab}}{\strut
474 % While this cell's text wraps, the previous cells (whose text
475 % doesn't wrap) determine the width of the column.} \\ \hline
476 % \end{tabular}
477 % \end{verbatim}
478 %
479 % \subsection{Lists within \texttt{tabular}s}
480 % \label{sec:lists-tabulars}
481 %
482 % List environments (|itemize|, |enumerate|, etc.) cannot appear
483 % directly within a |tabular| cell. Instead, they must be wrapped
484 % within a |\parbox|. The problem is that the |\parbox| width must be
485 % specified; it can't be determined automatically. Fortunately, as of
486 % version~4.0 of \pkgname{eqparbox}, the |\eqparbox| macro can contain
487 % list environments, and these are automatically sized to their widest
488 % item, just like any other |\eqparbox| contents.
489 % Table~\ref{tbl:lists-tabular} presents an example of |enumerate| lists
490 % appearing within |tabular| cells. The code for this is
491 % straightforward, thanks to \pkgname{eqparbox}:
492 %
493 % \begin{table}[tbp]
494 % \centering
495 % \caption{Lists within a \texttt{tabular}}
496 % \label{tbl:lists-tabular}
497 % \begin{tabular}{c|c}
498 % \textbf{Meeting date} & \textbf{Topics discussed} \\
499 % \hline
500 % 2017-02-22
501 % & \eqparbox{topiclist}{^^A
502 % \begin{enumerate}
503 % \item Hardware upgrades
504 % \item Barbara's retirement
505 % \item Revised 27B/6 paperwork
506 % \end{enumerate}
507 % }^^A
508 % \\ \hline
509 % 2017-03-01
510 % & \eqparbox{topiclist}{^^A
511 % \begin{enumerate}
512 % \item Printer low on toner
513 % \item Message from the V.P.
514 % \end{enumerate}
515 % }^^A
516 % \\ \hline
517 % 2017-03-08
518 % & \eqparbox{topiclist}{^^A
519 % \begin{enumerate}
520 % \item Product to ship next week
521 % \item Floors to be recarpeted
522 % \item Too many meetings
523 % \end{enumerate}
524 % }^^A
525 % \end{tabular}
526 % \end{table}
527 %
528 % \begin{verbatim}
529 % 2017-02-22 & \eqparbox{topiclist}{%
530 % \begin{enumerate}
531 % \item Hardware upgrades
532 % \item Barbara's retirement
533 % \item Revised 27B/6 paperwork
534 % \end{enumerate}
535 % } \\ \hline
536 % \end{verbatim}
537 %
538 % \subsection{Hanging indentation}
539 % \label{sec:hang-indent}
540 %
541 % Consider the paragraphs depicted in Figure~\ref{fig:hang-indent}.
542 % We'd like the paragraph labels set on the left, as shown, but we'd
543 % also like to allow both intra-~and inter-paragraph page breaks. Of
544 % course, if the labels are made wider or narrower, we'd like the
545 % paragraph widths to adjust automatically. By using a custom |list|
546 % environment that typesets its labels with |\eqparbox| this is fairly
547 % straightforward:
548 %
549 % \begin{verbatim}
550 % \begin{list}{}{%
551 % \renewcommand{\makelabel}[1]{\eqparbox[b]{listlab}{#1}}%
552 % \setlength{\labelwidth}{\eqboxwidth{listlab}}%
553 % \setlength{\labelsep}{2em}%
554 % \setlength{\parsep}{2ex plus 2pt minus 1pt}%
555 % \setlength{\itemsep}{0pt}%
556 % \setlength{\leftmargin}{\labelwidth+\labelsep}%
557 % \setlength{\rightmargin}{0pt}}
558 %
559 % \item[Stuff about me] I am great. Blah, blah, blah, ...
560 %
561 % \item[More stuff] I am wonderful. Blah, blah, blah, ...
562 %
563 % \item[The final exciting thing] I am fantastic. Blah,
564 % blah, blah, ...
565 % \end{list}
566 % \end{verbatim}
567 %
568 % \begin{figure}[htbp]
569 % \rule{\linewidth}{1pt}
570 % \begin{list}{}{^^A
571 % \renewcommand{\makelabel}[1]{\eqparbox[b]{listlab}{#1}}^^A
572 % \setlength{\labelwidth}{\eqboxwidth{listlab}}^^A
573 % \setlength{\labelsep}{2em}^^A
574 % \setlength{\parsep}{2ex plus 2pt minus 1pt}^^A
575 % \setlength{\itemsep}{0pt}^^A
576 % \setlength{\leftmargin}{\labelwidth}^^A
577 % \addtolength{\leftmargin}{\labelsep}^^A
578 % \setlength{\rightmargin}{0pt}}
579 %
580 % \item[Stuff about me] I am great. Blah, blah, blah, blah, blah,
581 % blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah,
582 % blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah,
583 % blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah,
584 % blah.
585 %
586 % \item[More stuff] I am wonderful. Blah, blah, blah, blah, blah,
587 % blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah,
588 % blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah,
589 % blah.
590 %
591 % Did I mention that blah, blah, blah, blah, blah, blah, blah, blah,
592 % blah, blah, blah, blah, blah, blah, blah?
593 %
594 % \item[The final exciting thing] I am fantastic. Blah, blah, blah,
595 % blah, blah, blah, blah, blah, blah, blah, blah, blah, blah, blah,
596 % blah, blah, blah, blah, blah, blah, blah, blah, blah.
597 % \end{list}
598 % \rule{\linewidth}{1pt}
599 % \caption{Paragraphs with hanging indentation}
600 % \label{fig:hang-indent}
601 % \end{figure}
602 %
603 % \subsection{Justified, parallel text}
604 % \label{sec:parallel-text}
605 %
606 % Consider line-by-line transcription of a piece of text as illustrated
607 % by the mockup in Figure~\ref{fig:line-by-line}. The idea is to
608 % juxtapose a scanned piece of handwritten text with its typeset version
609 % (or, similarly, to typeset a piece of text in one language alongside a
610 % line-by-line translation into another language). The challenge is in
611 % ensuring that (1)~the same words appear on corresponding lines of text
612 % and that (2)~the typeset text is fully justified. While the
613 % \pkgname{parallel} package can typeset fully justified paragraphs
614 % aligned in parallel columns, it does not support the alignment of
615 % individual lines. |tabular| and |minipage| environments provide
616 % control of line breaks but do not support full justification of the
617 % text when explicit line breaks are used.
618 %
619 % \begin{figure}[htbp]
620 % \centering
621 % \DeleteShortVerb{\|}
622 % \newsavebox{\tstretchbox}
623 % \newcolumntype{S}[1]{^^A
624 % >{\begin{lrbox}{\tstretchbox}}^^A
625 % l^^A
626 % <{\end{lrbox}^^A
627 % \eqmakebox[#1][s]{\unhcopy\tstretchbox}}}
628 % \begin{tabular}{|l|l|}
629 % \hline
630 % \calligra
631 % \begin{tabular}{S{handwritten}}
632 % Lorem ipsum dolor sit amet, \\
633 % consectetur adipiscing elit. \\
634 % Phasellus volutpat, nibh sit \\
635 % amet mattis convallis, metus \\
636 % libero rhoncus justo, sed auctor \\
637 % erat mauris sit amet tellus. \\
638 % \end{tabular}
639 % &
640 % \begin{tabular}{S{typeset}}
641 % Lorem ipsum dolor sit amet, \\
642 % consectetur adipiscing elit. \\
643 % Phasellus volutpat, nibh sit \\
644 % amet mattis convallis, metus \\
645 % libero rhoncus justo, sed auctor \\
646 % erat mauris sit amet tellus. \\
647 % \end{tabular} \\
648 % \hline
649 % \end{tabular}
650 % \MakeShortVerb{\|}
651 % \caption{Line-by-line transcription of text with full justification}
652 % \label{fig:line-by-line}
653 % \end{figure}
654 %
655 % One solution is to use \pkgname{eqparbox}'s |\eqmakebox| macro. Like
656 % |\makebox|, |\eqmakebox| supports the ``|s|'' (stretch) value for the
657 % \meta{pos} argument, which causes the \meta{text} argument to stretch
658 % to the width of the box. However, while |\makebox| requires the width
659 % to be specified explicitly, |\eqmakebox| automatically sizes all boxes
660 % that use the same tag (in this case, each line of the input paragraph)
661 % to the widest text's natural width. Here's how to use the
662 % \pkgname{array} package's |\newcolumntype| macro to define a new
663 % |tabular| column type, ``|S|'', that stretches whitespace as needed to
664 % fit the widest line in the column:
665 %
666 % \begin{verbatim}
667 % \newsavebox{\tstretchbox}
668 % \newcolumntype{S}[1]{%
669 % >{\begin{lrbox}{\tstretchbox}}%
670 % l%
671 % <{\end{lrbox}%
672 % \eqmakebox[#1][s]{\unhcopy\tstretchbox}}}
673 % \end{verbatim}
674 %
675 % \noindent
676 % That code works by storing the current cell's contents within a box
677 % called |\tstretchbox| then passing |\tstretchbox|'s contents to
678 % |\eqmakebox|. (The |tabular| environment does not enable a cell's
679 % contents to be passed directly to a macro, hence the |lrbox|
680 % trickery.) Note that the ``|S|'' column type takes an argument, which
681 % is the tag to pass to |\eqmakebox|. Using the preceding definition we
682 % can typeset Figure~\ref{fig:line-by-line} as follows. To simulate
683 % scanned handwriting in the left column we use the Calligra handwriting
684 % font provided by the \pkgname{calligra} package.
685 %
686 % \begin{verbatim}
687 % \begin{tabular}{|l|l|}
688 % \hline
689 % \calligra
690 % \begin{tabular}{S{handwritten}}
691 % Lorem ipsum dolor sit amet, \\
692 % consectetur adipiscing elit. \\
693 % Phasellus volutpat, nibh sit \\
694 % amet mattis convallis, metus \\
695 % libero rhoncus justo, sed auctor \\
696 % erat mauris sit amet tellus. \\
697 % \end{tabular}
698 % &
699 % \begin{tabular}{S{typeset}}
700 % Lorem ipsum dolor sit amet, \\
701 % consectetur adipiscing elit. \\
702 % Phasellus volutpat, nibh sit \\
703 % amet mattis convallis, metus \\
704 % libero rhoncus justo, sed auctor \\
705 % erat mauris sit amet tellus. \\
706 % \end{tabular} \\
707 % \hline
708 % \end{tabular}
709 % \end{verbatim}
710 %
711 % \subsection{Combining \texttt{l} and \texttt{p} column properties in a \texttt{tabular}}
712 % \label{sec:tabular-l-p}
713 %
714 % In a |tabular| environment, |l|~columns, which automatically fit the
715 % column to its contents, are good for short pieces of text. Long
716 % pieces of text are best set within a |p|~column, which wraps text
717 % within a specified width. But which column type should you use to
718 % typeset text whose width is unknown (e.g.,~if the text is generated
719 % programmatically)? With the help of \pkgname{eqparbox}'s
720 % |\eqsetmaxwidth| macro (and the \pkgname{array} package's
721 % |\newcolumntype| macro), it is possible to define a column type that
722 % behaves like~|l| for short pieces of text and like~|p| for long pieces
723 % of text:
724 %
725 % \begin{verbatim}
726 % \newcolumntype{M}[1]{%
727 % >{\begin{lrbox}{\csname#1box\endcsname}}%
728 % l%
729 % <{\end{lrbox}%
730 % \eqparbox[t]{#1}{\unhcopy\csname#1box\endcsname\strut}}%
731 % }
732 % \end{verbatim}
733 %
734 % This can then be used as follows to produce the output shown in
735 % Figure~\subref*{fig:maxwd-narrow}:
736 %
737 % \begin{verbatim}
738 % \eqsetmaxwidth{maybebig}{0.5\linewidth}
739 % \newsavebox{\maybebigbox}
740 % \begin{tabular}{|M{maybebig}|l|}
741 % \hline
742 % Very short & Good \\
743 % A little bit longer & Okay \\
744 % \end{tabular}
745 % \end{verbatim}
746 %
747 % \noindent
748 % Because the text in the first column is narrower than half the line
749 % width, the column behaves like an |l|~column. Now observe what
750 % happens if we add a long piece of text to the column:
751 %
752 % \begin{verbatim}
753 % \eqsetmaxwidth{maybebig}{0.5\linewidth}
754 % \newsavebox{\maybebigbox}
755 % \begin{tabular}{|M{maybebig}|l|}
756 % \hline
757 % Very short & Good \\
758 % A little bit longer & Okay \\
759 % Almost certainly excessively long, even given the point we're
760 % trying to make about box widths & Bad \\
761 % \end{tabular}
762 % \end{verbatim}
763 %
764 % \noindent
765 % As Figure~\subref*{fig:maxwd-wide} shows, the first column now behaves
766 % like a |p|~column, specifically |p{0.5\linewidth}|.
767 %
768 % \begin{figure}[htbp]
769 % \centering
770 % \subfloat[Output when the text is narrow\label{fig:maxwd-narrow}]{%
771 % \begin{tabular}{|l|l|}
772 % \hline
773 % Very short & Good \\
774 % A little bit longer & Okay \\
775 % \hline
776 % \end{tabular}%
777 % }
778 % \par
779 % \subfloat[Output when the text is wide\label{fig:maxwd-wide}]{%
780 % \begin{tabular}{|p{0.5\linewidth}|l|}
781 % \hline
782 % Very short & Good \\
783 % A little bit longer & Okay \\
784 % Almost certainly excessively long, even given the point we're
785 % trying to make about box widths & Bad \\
786 % \hline
787 % \end{tabular}%
788 % }
789 % \caption{Combining the features of \texttt{l} and \texttt{p} columns}
790 % \label{fig:maxwd}
791 % \end{figure}
792 %
793 % \subsection{Centering a column of right-justified data}
794 % \label{tbl:center-justified}
795 %
796 % The data in each of the Sales columns in Table~\ref{tbl:sales-data}
797 % are centered relative to their column header. However, they are also
798 % right-justified relative to each other. To achieve this effect we
799 % simply need to put the data in each column in a right-justified box
800 % using |\eqmakebox|\oarg{tag}|[r]|\marg{text} and center that:
801 %
802 % \begin{verbatim}
803 % \begin{tabular}{@{}lccc@{}} \hline
804 % & \multicolumn{3}{c}{Sales (in millions)} \\ \cline{2-4}
805 % \multicolumn{1}{c}{\raisebox{1ex}[2ex]{Product}} &
806 % October & November & December \\ \hline
807 %
808 % Widgets & \eqmakebox[oct][r]{ 55.2} &
809 % \eqmakebox[nov][r]{\bfseries 89.2} &
810 % \eqmakebox[dec][r]{ 57.9} \\
811 % Doohickeys & \eqmakebox[oct][r]{\bfseries 65.0} &
812 % \eqmakebox[nov][r]{\tiny N/A} &
813 % \eqmakebox[dec][r]{ 9.3} \\
814 % Thingamabobs & \eqmakebox[oct][r]{ 10.4} &
815 % \eqmakebox[nov][r]{ 8.0} &
816 % \eqmakebox[dec][r]{\bfseries 109.7} \\ \hline
817 % \end{tabular}
818 % \end{verbatim}
819 %
820 % \begin{table}[htbp]
821 % \centering
822 % \caption{Sample sales data}
823 % \label{tbl:sales-data}
824 % \begin{tabular}{@{}lccc@{}} \hline
825 % & \multicolumn{3}{c}{Sales (in millions)} \\ \cline{2-4}
826 % \multicolumn{1}{c}{\raisebox{1ex}[2ex]{Product}} &
827 % October & November & December \\ \hline
828 %
829 % Widgets & \eqmakebox[oct][r]{ 55.2} &
830 % \eqmakebox[nov][r]{\bfseries 89.2} &
831 % \eqmakebox[dec][r]{ 57.9} \\
832 % Doohickeys & \eqmakebox[oct][r]{\bfseries 65.0} &
833 % \eqmakebox[nov][r]{\tiny N/A} &
834 % \eqmakebox[dec][r]{ 9.3} \\
835 % Thingamabobs & \eqmakebox[oct][r]{ 10.4} &
836 % \eqmakebox[nov][r]{ 8.0} &
837 % \eqmakebox[dec][r]{\bfseries 109.7} \\ \hline
838 % \end{tabular}
839 % \end{table}
840 %
841 %
842 % \section{Limitations}
843 % \label{sec:limitations}
844 %
845 % Unfortunately, \pkgname{eqparbox}'s macros have a number of
846 % limitations not exhibited by the corresponding \LaTeXe\ commands.
847 % First, \pkgname{eqparbox}'s macros internally typeset the given text
848 % within a |tabular| environment---specifically, using ``|@{}l@{}|'' as
849 % the template---in order to determine the text's natural width.
850 % Consequently, commands not valid within such a |tabular|
851 % (e.g.,~|verbatim| environments) are also not valid within the
852 % \meta{text} argument of an \pkgname{eqparbox} macro. As a corollary,
853 % the macros defined by the \pkgname{eqparbox} package can appear only
854 % where a |tabular| is also acceptable.
855 %
856 % A second limitation is that \pkgname{eqparbox}'s macros typeset their
857 % \meta{text} argument \emph{twice}: once within a |tabular| to
858 % determine the natural width and again within a box wide enough to hold
859 % all text associated with tag \meta{tag}. This approach may cause
860 % unexpected results if \meta{text} is non-idempotent (i.e.,~has side
861 % effects). For example, if \meta{text} increments a counter, the
862 % counter will be incremented twice per invocation of |\eqparbox|.
863 %
864 % \StopEventually{}
865 %
866 % \section{Implementation}
867 % \label{sec:implementation}
868 %
869 % The one-sentence summary of the implementation is, ``As
870 % \pkgname{eqparbox} goes along, it keeps track of the maximum width of
871 % each box type, and when it's finished, it writes those widths to
872 % the~|.aux| file for use on subsequent runs.'' If you're satisfied
873 % with that summary, then read no further. Otherwise, get ready to
874 % tackle the following annotated code listing.
875 %
876 % \subsection{Preliminaries}
877 %
878 % \begin{macro}{\eqp@tempdima}
879 % \begin{macro}{\eqp@tempdimb}
880 % Define a couple temporary \meta{dimen}s for use in a variety of locations.
881 % \begin{macrocode}
882 \newlength{\eqp@tempdima}
883 \newlength{\eqp@tempdimb}
884 % \end{macrocode}
885 % \end{macro}
886 % \end{macro}
887 %
888 % \begin{macro}{\eqp@taglist}
889 % Define a list of all of the tags we encountered in the author's document.
890 % \begin{macrocode}
891 \def\eqp@taglist{}
892 % \end{macrocode}
893 % \end{macro}
894 %
895 % \begin{macro}{\ifeqp@must@rerun}
896 % \begin{macro}{\eqp@must@reruntrue}
897 % \begin{macro}{\eqp@must@rerunfalse}
898 % If an |eqparbox| is wider than the maximum-width |eqparbox| with the
899 % same tag, we need to store the new maximum width and request that the
900 % user re-run |latex|. We use |\ifeqp@must@rerun| and |\eqp@must@reruntrue|
901 % to assist with this.
902 % \begin{macrocode}
903 \newif\ifeqp@must@rerun
904 % \end{macrocode}
905 % \end{macro}
906 % \end{macro}
907 % \end{macro}
908 %
909 % The |\eqp@settowidth| macro requires the \pkgname{array} package's
910 % ability to inject code into every cell.
911 % \begin{macrocode}
912 \RequirePackage{array}
913 % \end{macrocode}
914 %
915 % \begin{macro}{\eqp@tabular@box}
916 % \begin{macro}{\eqp@list@box}
917 % The |\eqp@settowidth| macro requires a box, |\eqp@tabular@box|, in
918 % which to store the entire input text. |\eqp@settowidth| also requires
919 % a box, |\eqp@list@box|, in which to store nested |list| environments.
920 % \begin{macrocode}
921 \newsavebox{\eqp@tabular@box}
922 \newsavebox{\eqp@list@box}
923 % \end{macrocode}
924 % \end{macro}
925 % \end{macro}
926 %
927 % \begin{macro}{\eqp@list@indent}
928 % The |\eqp@settowidth| macro stores the accumulated |list| indentation
929 % in |\eqp@list@indent|.
930 % \begin{macrocode}
931 \newlength{\eqp@list@indent}
932 % \end{macrocode}
933 % \end{macro}
934 %
935 % The |eqminipage| environment requires the \pkgname{environ} package's
936 % |\Collect@Body|, which passes the body of an environment to a macro as
937 % a single argument.
938 % \begin{macrocode}
939 \RequirePackage{environ}
940 % \end{macrocode}
941 %
942 %
943 % \subsection{Width calculation}
944 %
945 % \begin{macro}{\eqp@storefont}
946 % \begin{macro}{\eqp@restorefont}
947 % To find the natural width of a piece of text, we put it in a table and
948 % take the width of that. The problem is that font changes are not
949 % preserved across line breaks (table cells). We therefore define an
950 % |\eqp@storefont| macro which itself defines an |\eqp@restorefont|
951 % macro that restores the current font and font size to its current
952 % state.
953 % \begin{macrocode}
954 \newcommand*{\eqp@storefont}{%
955 \xdef\eqp@restorefont{%
956 \noexpand\usefont{\f@encoding}{\f@family}{\f@series}{\f@shape}%
957 \noexpand\fontsize{\f@size}{\f@baselineskip}%
958 \noexpand\selectfont
959 }%
960 }
961 % \end{macrocode}
962 % \end{macro}
963 % \end{macro}
964 %
965 % \begin{macro}{\eqp@settowidth}
966 % This macro is just like |\settowidth|, but it puts its argument in a
967 % |tabular|, which means that it can contain |\\|. We use the
968 % \pkgname{array} package's ``|>|'' and ``|<|'' template parameters to
969 % inject an |\eqp@restorefont| at the start of every cell and an
970 % |\eqp@storefont| at the end of every cell. Doing so preserves fonts
971 % and font sizes across |\\| boundaries, just like |\parbox|.
972 %
973 % One catch is that lists cannot be included directly within a
974 % |tabular|. True, they can be placed within a |\parbox| that itself is
975 % within a |tabular| cell, but the whole point is that we're trying to
976 % calculate how wide that |\parbox| should be, The trick we use here,
977 % therefore, is to redefine the |list| environment as a single-column
978 % |tabular| plus space for |\labelwidth| and |\labelsep|---we ignore all
979 % other list-formatting parameters---and |\item| as~|\\|. There will be
980 % an extra row at the beginning, but all we care about here is computing
981 % a width, not a height, so that's acceptable.
982 % \changes{v2.0}{2004/08/01}{Modified to store and restore the font
983 % across \texttt{\string\string\string\\}~boundaries (suggested by
984 % Mike Shell)}
985 % \changes{v4.0}{2013/03/09}{Added support for list environments}
986 % \changes{v4.0}{2013/03/15}{Added support for multi-paragraph input}
987 % \begin{macrocode}
988 \newcommand{\eqp@settowidth}[2]{%
989 \begingroup
990 \global\setbox\eqp@tabular@box=\hbox{%
991 % \end{macrocode}
992 % \begin{macro}{\eqp@endings}
993 % Unfortunately, we can't simply redefine the |list| environment, which
994 % underlies |itemize|, |enumerate|, and |description| lists, because
995 % their definitions in the standard classes do not include a proper
996 % |\begin{list}|\dots\linebreak[0]|\end{list}|. Instead, those parent
997 % environments call |\list| directly and
998 % |\let\end|\{|itemize|,\linebreak[0]|enumerate|,\linebreak[0]|description|\}|=\endlist|.
999 % Our workaround is to reissue those |\let| bindings after redefining
1000 % |\list| and |\endlist| ourselves.
1001 % \begin{macrocode}
1002 \def\eqp@endings{}%
1003 \ifx\enditemize\endlist
1004 \g@addto@macro\eqp@endings{\let\enditemize=\endlist}%
1005 \fi
1006 \ifx\endenumerate\endlist
1007 \g@addto@macro\eqp@endings{\let\endenumerate=\endlist}%
1008 \fi
1009 \ifx\enddescription\endlist
1010 \g@addto@macro\eqp@endings{\let\enddescription=\endlist}%
1011 \fi
1012 % \end{macrocode}
1013 % \begin{environment}{list}
1014 % As described above, we locally redefine the |list| environment as a
1015 % single-column |tabular| and the |\item| macro as~|\\|. We begin by
1016 % copying a block of code from |ltlists.dtx| that sets the default
1017 % formatting parameters for a list of the current depth. This is
1018 % important because |trivlist| environments (e.g.,~|center| and
1019 % |flushleft|) reset some of the parameters, which would otherwise screw
1020 % up our width calculation.
1021 % \begin{macrocode}
1022 \renewenvironment{list}[2]{%
1023 \ifnum \@listdepth >5\relax
1024 \@toodeep
1025 \else
1026 \global\advance\@listdepth\@ne
1027 \fi
1028 \rightmargin\z@
1029 \listparindent\z@
1030 \itemindent\z@
1031 \csname @list\romannumeral\the\@listdepth\endcsname
1032 ##2\relax
1033 % \end{macrocode}
1034 % \begin{macro}{\item}
1035 % We locally redefine |\item| to start a new row of the |tabular|, then
1036 % flush any nested lists from the previous |\item| at the current
1037 % nesting level, and finally adjust the current indentation based on
1038 % the item's label.
1039 % \begin{macrocode}
1040 \renewcommand*{\item}[1][]{%
1041 \mbox{}\\
1042 \box\eqp@list@box\mbox{} \\
1043 \sbox\@tempboxa{\makelabel{####1}}%
1044 \ifdim\wd\@tempboxa>\labelwidth
1045 \advance\eqp@list@indent by -\labelwidth
1046 \advance\eqp@list@indent by \wd\@tempboxa
1047 \fi
1048 \hspace*{\eqp@list@indent}%
1049 }%
1050 % \end{macrocode}
1051 % To measure the width of a |list| we introduce a single-column
1052 % |tabular| that includes |\eqp@list@indent|'s worth of padding
1053 % ($=$~|\leftmargin|~$+$ |\rightmargin|~$+$ |\itemindent|)
1054 % to mimic the width of the original |list| environment.
1055 % \begin{macrocode}
1056 \hspace*{-\eqp@list@indent}%
1057 \advance\eqp@list@indent by \leftmargin
1058 \advance\eqp@list@indent by \rightmargin
1059 \advance\eqp@list@indent by \itemindent
1060 \global\setbox\eqp@list@box=\hbox\bgroup
1061 \begin{tabular}{@{}l@{}}%
1062 }{%
1063 \item[]%
1064 \end{tabular}%
1065 \egroup
1066 \global\advance\@listdepth\m@ne
1067 }%
1068 \eqp@endings
1069 % \end{macrocode}
1070 % Finally, we place the given text---list or not---within a |tabular| so
1071 % the preceding |\settowidth| can measure its width. Because the text
1072 % may contain paragraph breaks we redefine |\par| as~|\\| to turn them
1073 % into line breaks and restore |\par|'s original definition when the
1074 % |tabular| ends.
1075 % \begin{macrocode}
1076 \global\let\eqp@par=\par
1077 \eqp@storefont
1078 \begin{tabular}{@{}>{\eqp@restorefont}l<{\eqp@storefont}@{}}%
1079 \global\@setpar{\\}%
1080 #2%
1081 \\ \box\eqp@list@box
1082 \end{tabular}%
1083 \global\@restorepar
1084 }%
1085 \endgroup
1086 % \end{macrocode}
1087 % Now that we've constructed a |tabular| with lines of the input text as
1088 % cells we can use \LaTeX's |\settowidth| macro to take its width.
1089 % \begin{macrocode}
1090 \settowidth{#1}{\box\eqp@tabular@box}%
1091 }
1092 % \end{macrocode}
1093 % \end{macro}
1094 % \end{environment}
1095 % \end{macro}
1096 % \end{macro}
1097 %
1098 % \begin{macro}{\eqp@compute@width}
1099 % The following function does all the real work for the
1100 % \pkgname{eqparbox} package. It takes two parameters---\meta{tag} and
1101 % \meta{text}---and ensures that all boxes with the same tag will be as
1102 % wide as the widest box with that tag. It ends by passing \meta{tag}
1103 % and \meta{text} to the |\eqp@produce@box| command, which was defined
1104 % by the calling macro to produce a box using one of the existing
1105 % \LaTeXe\ commands.
1106 %
1107 % To keep track of box widths, |\eqp@compute@width| makes use of two global
1108 % variables for each tag: |\eqp@this@|\meta{tag} and
1109 % |\eqp@next|\meta{tag}. |\eqp@this@|\meta{tag} is the maximum width
1110 % ever seen for tag \meta{tag}, including in previous |latex| runs.
1111 % |\eqp@next@|\meta{tag} works the same way but is always initialized
1112 % to~|0.0pt|. It represents the maximum width to assume in
1113 % \emph{subsequent} |latex| runs. It is needed to detect whether the
1114 % widest text with tag \meta{tag} has been removed/shrunk. At the end of
1115 % a run, \pkgname{eqparbox} prepares the next run (via the~|.aux| file)
1116 % to initialize |\eqp@this@|\meta{tag} to the final value of
1117 % |\eqp@next@|\meta{tag}.
1118 % \changes{v2.0}{2004/07/30}{Removed extraneous \texttt{\string\string\string\global}s
1119 % (suggested by David Kastrup)}
1120 % \changes{v3.1}{2010/01/01}{Restructured the package to make all
1121 % user-callable functions eventually call
1122 % \texttt{\string\string\string\eqp@compute@width}, which does the
1123 % bulk of the work}
1124 % \begin{macrocode}
1125 \long\def\eqp@compute@width#1#2{%
1126 \eqp@settowidth{\eqp@tempdimb}{#2}%
1127 % \end{macrocode}
1128 % We first clamp the box width, currently in |\eqp@tempdimb|, to the
1129 % range [|\eqp@minwd@|\meta{tag}, |\eqp@maxwd@|\meta{tag}]. As these
1130 % bounds are not necessarily defined we first have to check for their
1131 % existence.
1132 % \begin{macrocode}
1133 \@ifundefined{eqp@minwd@#1}{}{%
1134 \ifdim\eqp@tempdimb<\csname eqp@minwd@#1\endcsname
1135 \eqp@tempdimb=\csname eqp@minwd@#1\endcsname
1136 \fi
1137 }%
1138 \@ifundefined{eqp@maxwd@#1}{}{%
1139 \ifdim\eqp@tempdimb>\csname eqp@maxwd@#1\endcsname
1140 \eqp@tempdimb=\csname eqp@maxwd@#1\endcsname
1141 \fi
1142 }%
1143 \expandafter
1144 \ifx\csname eqp@this@#1\endcsname\relax
1145 % \end{macrocode}
1146 % If we get here, then we've never encountered tag \meta{tag}, even in
1147 % a previous |latex| run. We request that the user re-run |latex|.
1148 % This is not always necessary (e.g.,~when all uses of the |\eqparbox|
1149 % with tag \meta{tag} are left-justified), but it's better to be safe
1150 % than sorry.
1151 % \begin{macrocode}
1152 \global\eqp@must@reruntrue
1153 \expandafter\xdef\csname eqp@this@#1\endcsname{\the\eqp@tempdimb}%
1154 \expandafter\xdef\csname eqp@next@#1\endcsname{\the\eqp@tempdimb}%
1155 \else
1156 % \end{macrocode}
1157 % If we get here, then we \emph{have} previously seen tag \meta{tag}.
1158 % We just have to keep track of the maximum text width associated with
1159 % it.
1160 % \begin{macrocode}
1161 \eqp@tempdima=\csname eqp@this@#1\endcsname\relax
1162 \ifdim\eqp@tempdima<\eqp@tempdimb
1163 \expandafter\xdef\csname eqp@this@#1\endcsname{\the\eqp@tempdimb}%
1164 \global\eqp@must@reruntrue
1165 \fi
1166 % \end{macrocode}
1167 % \begin{macrocode}
1168 \eqp@tempdima=\csname eqp@next@#1\endcsname\relax
1169 \ifdim\eqp@tempdima<\eqp@tempdimb
1170 \expandafter\xdef\csname eqp@next@#1\endcsname{\the\eqp@tempdimb}%
1171 \fi
1172 \fi
1173 % \end{macrocode}
1174 %
1175 % The first time we encounter tag \meta{tag} in the current document we
1176 % ensure \LaTeX{} will notify the user if he needs to re-run |latex| on
1177 % account of that tag.
1178 % \begin{macrocode}
1179 \@ifundefined{eqp@seen@#1}{%
1180 \expandafter\gdef\csname eqp@seen@#1\endcsname{}%
1181 \@cons\eqp@taglist{{#1}}%
1182 }{}%
1183 % \end{macrocode}
1184 %
1185 % Finally, we can call |\eqp@produce@box|. We pass it
1186 % |\eqp@this@|\meta{tag} for its \meta{width} argument and |#2| for its
1187 % \meta{text} argument.
1188 % \begin{macrocode}
1189 \eqp@tempdima=\csname eqp@this@#1\endcsname\relax
1190 \eqp@produce@box{\eqp@tempdima}{#2}%
1191 }
1192 % \end{macrocode}
1193 % \end{macro}
1194 %
1195 % \begin{macro}{\eqp@set@min@width}
1196 % Given a tag and a textual length, ensure that |\eqp@this@|\meta{tag}
1197 % represents a width of at least \meta{length}.
1198 % \changes{v4.1}{2017/09/03}{Introduced this helper macro for
1199 % \texttt{\string\string\string\eqsetminwidth} and
1200 % \texttt{\string\string\string\eqsetminwidthto}}
1201 % \begin{macrocode}
1202 \def\eqp@set@min@width#1#2{%
1203 \expandafter\ifx\csname eqp@this@#1\endcsname\relax
1204 % \end{macrocode}
1205 % If we get here, then we've never encountered tag \meta{tag}, even in
1206 % a previous |latex| run. We assign a value to \meta{tag} and request
1207 % that the user re-run |latex|.
1208 % \begin{macrocode}
1209 \global\eqp@must@reruntrue
1210 \expandafter\xdef\csname eqp@this@#1\endcsname{#2}%
1211 \expandafter\xdef\csname eqp@next@#1\endcsname{#2}%
1212 \else
1213 % \end{macrocode}
1214 % If we get here, then we \emph{have} previously seen tag \meta{tag}.
1215 % We ensure its width is at least~|#2|.
1216 % \begin{macrocode}
1217 \eqp@tempdima=\csname eqp@this@#1\endcsname\relax
1218 \eqp@tempdimb=#2\relax
1219 \ifdim\eqp@tempdima<\eqp@tempdimb
1220 \expandafter\xdef\csname eqp@this@#1\endcsname{\the\eqp@tempdimb}%
1221 \fi
1222 \eqp@tempdima=\csname eqp@next@#1\endcsname\relax
1223 \ifdim\eqp@tempdima<\eqp@tempdimb
1224 \expandafter\xdef\csname eqp@next@#1\endcsname{\the\eqp@tempdimb}%
1225 \fi
1226 \fi
1227 \@ifundefined{eqp@seen@#1}{%
1228 \expandafter\gdef\csname eqp@seen@#1\endcsname{}%
1229 \@cons\eqp@taglist{{#1}}%
1230 }{}%
1231 }
1232 % \end{macrocode}
1233 % \end{macro}
1234 %
1235 %
1236 % \subsection{Author macros}
1237 %
1238 % \begin{macro}{\eqparbox}
1239 % We want |\eqparbox| to take the same arguments as |\parbox|, with the
1240 % same default values for the optional arguments. The only difference
1241 % in argument processing is that |\eqparbox| has a \meta{tag} argument
1242 % where |\parbox| has \meta{width}.
1243 %
1244 % Because |\eqparbox| has more than one optional argument, we can't use
1245 % a single function defined by |\DeclareRobustCommand|. Instead, we
1246 % have to split |\eqparbox| into |\eqparbox|, |\eqparbox@i|,
1247 % |\eqparbox@ii|, and |\eqparbox@iii| macros, which correspond to
1248 % |\parbox|, |\@iparbox|, |\@iiparbox|, and |\@iiiparbox| in
1249 % |ltboxes.dtx|.
1250 %
1251 % |\eqparbox| takes an optional \meta{pos} argument that defaults
1252 % to~|c|. It passes the value of this argument to |\eqparbox@i|.
1253 % \begin{macrocode}
1254 \DeclareRobustCommand{\eqparbox}{%
1255 \@ifnextchar[%]
1256 {\eqparbox@i}%
1257 {\eqparbox@iii[c][\relax][s]}%
1258 }
1259 % \end{macrocode}
1260 % \end{macro}
1261 %
1262 % \begin{macro}{\eqparbox@i}
1263 % |\eqparbox@i| takes a \meta{pos} argument followed by an optional
1264 % \meta{height} argument that defaults to~|\relax|. It passes both
1265 % \meta{pos} and \meta{height} to |\eqparbox@ii|.
1266 % \begin{macrocode}
1267 \def\eqparbox@i[#1]{%
1268 \@ifnextchar[%]
1269 {\eqparbox@ii[#1]}%
1270 {\eqparbox@iii[#1][\relax][s]}%
1271 }
1272 % \end{macrocode}
1273 % \end{macro}
1274 %
1275 % \begin{macro}{\eqparbox@ii}
1276 % |\eqparbox@ii| takes \meta{pos} and \meta{height} arguments followed
1277 % by an optional \meta{inner-pos} argument that defaults to \meta{pos}.
1278 % It passes \meta{pos}, \meta{height}, and \meta{inner-pos} to
1279 % |\eqparbox@iii|.
1280 % \begin{macrocode}
1281 \def\eqparbox@ii[#1][#2]{%
1282 \@ifnextchar[%]
1283 {\eqparbox@iii[#1][#2]}%
1284 {\eqparbox@iii[#1][#2][#1]}%
1285 }
1286 % \end{macrocode}
1287 % \end{macro}
1288 % \begin{macro}{\eqparbox@iii}
1289 % \begin{macro}{\eqp@produce@box}
1290 % |\eqparbox@iii| takes \meta{pos}, \meta{height} and \meta{inner-pos}
1291 % arguments. It defines an |\eqp@produce@box| macro that takes a
1292 % \meta{width} argument and a \meta{text} argument and passes all of
1293 % \meta{pos}, \meta{height}, \meta{inner-pos}, \meta{width}, and
1294 % \meta{text} to \LaTeX's |\parbox| macro. |\eqparbox@iii| ends by
1295 % calling |\eqp@compute@width|, which will eventually invoke
1296 % |\eqp@produce@box|.
1297 % \begin{macrocode}
1298 \def\eqparbox@iii[#1][#2][#3]{%
1299 \long\gdef\eqp@produce@box##1##2{%
1300 \parbox[#1][#2][#3]{##1}{##2}%
1301 }%
1302 \eqp@compute@width
1303 }
1304 % \end{macrocode}
1305 % \end{macro}
1306 % \end{macro}
1307 %
1308 % \begin{environment}{eqminipage}
1309 % The |eqminipage| environment is implemented almost exactly like the
1310 % |\eqparbox| macro above. Just like |\eqparbox|, |eqminipage| takes an
1311 % optional \meta{pos} argument that defaults to~|c|. It passes the
1312 % value of this argument to |\eqminipage@i|.
1313 % \changes{v4.0}{2013/03/14}{Introduced this environment}
1314 % \begin{macrocode}
1315 \DeclareRobustCommand{\eqminipage}{%
1316 \@ifnextchar[%]
1317 {\eqminipage@i}%
1318 {\eqminipage@iii[c][\relax][s]}%
1319 }
1320 \let\endeqpminipage=\relax
1321 % \end{macrocode}
1322 % \end{environment}
1323 %
1324 % \begin{macro}{\eqminipage@i}
1325 % |\eqminipage@i| takes a \meta{pos} argument followed by an optional
1326 % \meta{height} argument that defaults to~|\relax|. It passes both
1327 % \meta{pos} and \meta{height} to |\eqminipage@ii|.
1328 % \begin{macrocode}
1329 \long\def\eqminipage@i[#1]{%
1330 \@ifnextchar[%]
1331 {\eqminipage@ii[#1]}%
1332 {\eqminipage@iii[#1][\relax][s]}%
1333 }
1334 % \end{macrocode}
1335 % \end{macro}
1336 %
1337 % \begin{macro}{\eqminipage@ii}
1338 % |\eqminipage@ii| takes \meta{pos} and \meta{height} arguments followed
1339 % by an optional \meta{inner-pos} argument that defaults to \meta{pos}.
1340 % It passes \meta{pos}, \meta{height}, and \meta{inner-pos} to
1341 % |\eqminipage@iii|.
1342 % \begin{macrocode}
1343 \def\eqminipage@ii[#1][#2]{%
1344 \@ifnextchar[%]
1345 {\eqminipage@iii[#1][#2]}%
1346 {\eqminipage@iii[#1][#2][#1]}%
1347 }
1348 % \end{macrocode}
1349 % \end{macro}
1350 % \begin{macro}{\eqminipage@iii}
1351 % This is where |eqminipage| differs from |\eqparbox|. Like
1352 % |\eqparbox@iii|, |\eqminipage@iii| takes \meta{pos}, \meta{height} and
1353 % \meta{inner-pos} arguments. However, while |\eqparbox@iii| expects to
1354 % be followed by a tag and text, |\eqminipage@iii| consumes the tag
1355 % itself. |\eqminipage@iii| then uses \pkgname{environ}'s
1356 % |\Collect@Body| macro to collect everything up to the
1357 % |\end{eqminipage}| into a single argument, which it passes to
1358 % |\eqminipage@iv|.
1359 % \begin{macrocode}
1360 \def\eqminipage@iii[#1][#2][#3]#4{%
1361 % \end{macrocode}
1362 % \begin{macro}{\eqminipage@iv}
1363 % \begin{macro}{\eqp@produce@box}
1364 % This code is a bit confusing due to the definition of a macro within a
1365 % macro within a macro. |\eqminipage@iv|, which is invoked by
1366 % |\collect@body|, is passed the body of the |eqminipage| environment as
1367 % an argument. In then defines an |\eqp@produce@box| macro with the
1368 % parameter list that |\eqp@compute@width| expects: a width (|####1|)
1369 % and text (|####2|). |\eqp@produce@box| typesets a |minipage| with
1370 % that width and text and the formatting parameters provided to
1371 % |\eqminipage@iii| (|#1|, |#2|, and~|#3|). Finally, |\eqminipage@iv|
1372 % invokes |\eqp@compute@width| with the tag passed to |\eqminipage@iii|
1373 % as~|#4| and the text passed to |\eqminipage@iv| as~|##1|.
1374 % \begin{macrocode}
1375 \long\def\eqminipage@iv##1{%
1376 \long\gdef\eqp@produce@box####1####2{%
1377 \begin{minipage}[#1][#2][#3]{####1}%
1378 ####2%
1379 \end{minipage}%
1380 }%
1381 \eqp@compute@width{#4}{##1}%
1382 }%
1383 \Collect@Body\eqminipage@iv
1384 }
1385 % \end{macrocode}
1386 % \end{macro}
1387 % \end{macro}
1388 % \end{macro}
1389 %
1390 % \begin{macro}{\eqmakebox}
1391 % |\eqmakebox| provides an automatic-width analogue to \LaTeX's
1392 % |\makebox|. It takes the same arguments as |\makebox| with the same
1393 % default values for the optional arguments. The only difference in
1394 % argument processing is that |\eqmakebox| has a \meta{tag} argument
1395 % where |\makebox| has \meta{width}. Note that if \meta{width} is not
1396 % specified, |\eqmakebox| simply invokes |\makebox|.
1397 % \changes{v3.0}{2010/01/01}{Included Rob Verhoeven's
1398 % \texttt{\string\string\string\eqmakebox} macro}
1399 % \changes{v3.1}{2010/01/01}{Modified the argument processing to match
1400 % \texttt{\string\string\string\makebox}'s}
1401 % \begin{macrocode}
1402 \DeclareRobustCommand{\eqmakebox}{%
1403 \@ifnextchar[%]
1404 {\eqlrbox@i\makebox}%
1405 {\makebox}%
1406 }
1407 % \end{macrocode}
1408 % \end{macro}
1409 %
1410 % \begin{macro}{\eqframebox}
1411 % |\eqframebox| provides an automatic-width analogue to \LaTeX's
1412 % |\framebox|. It takes the same arguments as |\framebox| with the same
1413 % default values for the optional arguments. The only difference in
1414 % argument processing is that |\eqframebox| has a \meta{tag} argument
1415 % where |\framebox| has \meta{width}. Note that if \meta{width} is not
1416 % specified, |\eqframebox| simply invokes |\framebox|.
1417 % \changes{v3.1}{2010/01/01}{Introduced this macro}
1418 % \begin{macrocode}
1419 \DeclareRobustCommand{\eqframebox}{%
1420 \@ifnextchar[%]
1421 {\eqlrbox@i\framebox}%
1422 {\framebox}%
1423 }
1424 % \end{macrocode}
1425 % \end{macro}
1426 %
1427 % \begin{macro}{\eqsavebox}
1428 % |\eqsavebox| provides an automatic-width analogue to \LaTeX's
1429 % |\savebox|. It takes the same arguments as |\savebox| with the same
1430 % default values for the optional arguments. The only difference in
1431 % argument processing is that |\eqsavebox| has a \meta{tag} argument
1432 % where |\savebox| has \meta{width}. Note that if \meta{width} is not
1433 % specified, |\eqsavebox| simply invokes |\savebox|.
1434 % \changes{v3.1}{2010/01/01}{Introduced this macro}
1435 % \begin{macrocode}
1436 \DeclareRobustCommand{\eqsavebox}[1]{%
1437 \@ifnextchar[%]
1438 {\eqlrbox@i{\savebox{#1}}}%
1439 {\savebox{#1}}%
1440 }
1441 % \end{macrocode}
1442 % \end{macro}
1443 %
1444 % \begin{macro}{\eqlrbox@i}
1445 % |\eqlrbox@i| takes a \marg{command} argument (one of |\makebox|,
1446 % |\framebox|, or |\savebox|\marg{cmd}) and a \oarg{tag} argument and
1447 % checks if those arguments are followed by a \oarg{pos} argument. If
1448 % not, then \meta{pos} defaults to ``|c|''. All of \meta{command},
1449 % \meta{tag}, and \meta{pos} are passed to |\eqlrbox@ii|.
1450 % \begin{macrocode}
1451 \def\eqlrbox@i#1[#2]{%
1452 \@ifnextchar[%]
1453 {\eqlrbox@ii{#1}[#2]}%
1454 {\eqlrbox@ii{#1}[#2][c]}%
1455 }
1456 % \end{macrocode}
1457 % \end{macro}
1458 %
1459 % \begin{macro}{\eqlrbox@ii}
1460 % \begin{macro}{\eqp@produce@box}
1461 % |\eqlrbox@i| takes a \marg{command} argument (one of |\makebox|,
1462 % |\framebox|, or |\savebox|\marg{cmd}), a \oarg{tag} argument, and a
1463 % \oarg{pos} argument. It defines |\eqp@produce@box| to take a
1464 % \meta{width} argument and a \meta{text} argument and invoke
1465 % \meta{command}\oarg{width}\oarg{pos}\marg{text}. |\eqlrbox@ii| ends
1466 % by calling |\eqp@compute@width|, which will eventually invoke
1467 % |\eqp@produce@box|.
1468 % \begin{macrocode}
1469 \def\eqlrbox@ii#1[#2][#3]{%
1470 \long\gdef\eqp@produce@box##1##2{%
1471 #1[##1][#3]{##2}%
1472 }%
1473 \eqp@compute@width{#2}%
1474 }
1475 % \end{macrocode}
1476 % \end{macro}
1477 % \end{macro}
1478 %
1479 % \begin{macro}{\eqboxwidth}
1480 % For the times that the user wants to make something other than a box to
1481 % match an |\eqparbox|'s width, we provide |\eqboxwidth|. |\eqboxwidth|
1482 % returns the width of a box corresponding to a given tag. More
1483 % precisely, if |\eqp@this@|\meta{tag} is defined, it's returned.
1484 % Otherwise,~|0pt| is returned.
1485 % \changes{v2.1}{2004/08/02}{Rewrote so as to be compatible with the
1486 % \pkgname{calc} package's \texttt{\string\string\string\setlength}
1487 % command (problem initially reported by Gary L. Gray and narrowed
1488 % down by Martin Vaeth)}
1489 % \begin{macrocode}
1490 \newcommand*{\eqboxwidth}[1]{%
1491 \@ifundefined{eqp@this@#1}{0pt}{\csname eqp@this@#1\endcsname}%
1492 }
1493 % \end{macrocode}
1494 % \end{macro}
1495 %
1496 % \begin{macro}{\eqsetminwidth}
1497 % The |\eqsetminwidth| macro accepts a tag and a length and records that
1498 % the user wants the associated box to be no narrower than the given
1499 % length.
1500 % \changes{v4.0}{2013/03/04}{Introduced this macro}
1501 % \changes{v4.1}{2017/09/03}{Define
1502 % \texttt{\string\string\string\eqp@this@}\meta{tag} and
1503 % \texttt{\string\string\string\eqp@next@}\meta{tag} appropriately}
1504 % \begin{macrocode}
1505 \newcommand{\eqsetminwidth}[2]{%
1506 \@tempdima=#2\relax
1507 \expandafter\xdef\csname eqp@minwd@#1\endcsname{\the\@tempdima}%
1508 \eqp@set@min@width{#1}{\csname eqp@minwd@#1\endcsname}%
1509 }
1510 % \end{macrocode}
1511 % \end{macro}
1512 %
1513 % \begin{macro}{\eqsetmaxwidth}
1514 % The |\eqsetmaxwidth| macro accepts a tag and a length and records that
1515 % the user wants the associated box to be no wider than the given
1516 % length.
1517 % \changes{v4.0}{2013/03/04}{Introduced this macro}
1518 % \begin{macrocode}
1519 \newcommand{\eqsetmaxwidth}[2]{%
1520 \@tempdima=#2\relax
1521 \expandafter\xdef\csname eqp@maxwd@#1\endcsname{\the\@tempdima}%
1522 }
1523 % \end{macrocode}
1524 % \end{macro}
1525 %
1526 % \begin{macro}{\eqsetminwidthto}
1527 % The |\eqsetminwidthto| macro accepts a tag and a piece of text and
1528 % records that the user wants the associated box to be no narrower than
1529 % the text, typeset at its natural width.
1530 % \changes{v4.0}{2013/03/04}{Introduced this macro}
1531 % \changes{v4.1}{2017/09/03}{Define
1532 % \texttt{\string\string\string\eqp@this@}\meta{tag} and
1533 % \texttt{\string\string\string\eqp@next@}\meta{tag} appropriately}
1534 % \begin{macrocode}
1535 \newcommand{\eqsetminwidthto}[2]{%
1536 \eqp@settowidth{\@tempdima}{#2}%
1537 \expandafter\xdef\csname eqp@minwd@#1\endcsname{\the\@tempdima}%
1538 \eqp@set@min@width{#1}{\csname eqp@minwd@#1\endcsname}%
1539 }
1540 % \end{macrocode}
1541 % \end{macro}
1542 %
1543 % \begin{macro}{\eqsetmaxwidthto}
1544 % The |\eqsetmaxwidthto| macro accepts a tag and a piece of text and
1545 % records that the user wants the associated box to be no wider than
1546 % the text, typeset at its natural width.
1547 % \changes{v4.0}{2013/03/04}{Introduced this macro}
1548 % \begin{macrocode}
1549 \newcommand{\eqsetmaxwidthto}[2]{%
1550 \eqp@settowidth{\@tempdima}{#2}%
1551 \expandafter\xdef\csname eqp@maxwd@#1\endcsname{\the\@tempdima}%
1552 }
1553 % \end{macrocode}
1554 % \end{macro}
1555 %
1556 % \subsection{End-of-document processing}
1557 %
1558 % At the |\end{document}|, for each tag \meta{tag} we see if
1559 % |\eqp@next@|\meta{tag}, which was initialized to~|0.0pt|, is different
1560 % from |\eqp@this@|\meta{tag}, which was initialized to the maximum box
1561 % width from the previous run. If so, we issue an informational
1562 % message. In any case, we initialize the next run's
1563 % |\eqp@this@|\meta{tag} to |\eqp@next@|\meta{tag} and the next run's
1564 % |\eqp@next@|\meta{tag} to |0pt|.
1565 % \begin{macrocode}
1566 \AtEndDocument{%
1567 \begingroup
1568 % \end{macrocode}
1569 % \begin{macro}{\@elt}
1570 % The |\eqp@taglist| list is of the form ``|\@elt| |{|\meta{tag$_1$}|}|
1571 % |\@elt| |{|\meta{tag$_2$}|}|~\ldots''. We therefore locally define
1572 % |\@elt| to take the name of a tag and perform all of the checking
1573 % described above and then merely execute |\eqp@taglist|.
1574 % \changes{v2.0}{2004/08/01}{Modified to allow numbers in tag names
1575 % (suggested by Martin Vaeth)}
1576 % \changes{v4.0}{2013/03/04}{Modified to honor minimum and maximum
1577 % text widths, as set by
1578 % \texttt{\string\string\string\eqset}\{\texttt{max},\texttt{min}\}\texttt{width} and
1579 % \texttt{\string\string\string\eqset}\{\texttt{max},\texttt{min}\}\texttt{widthto}}
1580 % \begin{macrocode}
1581 \def\@elt#1{%
1582 % \end{macrocode}
1583 % Complain if the tag's minimum width is greater than its maximum width.
1584 % \begin{macrocode}
1585 \@ifundefined{eqp@minwd@#1}{}{%
1586 \@ifundefined{eqp@maxwd@#1}{}{%
1587 \ifdim\csname eqp@minwd@#1\endcsname>\csname eqp@maxwd@#1\endcsname
1588 \PackageWarning{eqparbox}{For tag `#1',
1589 minimum width (\csname eqp@minwd@#1\endcsname) >
1590 maximum width (\csname eqp@maxwd@#1\endcsname)}%
1591 \fi
1592 }%
1593 }%
1594 % \end{macrocode}
1595 % Make the |.aux| file define |\eqp@this@|\meta{tag} to the current
1596 % value of |\eqp@next@|\meta{tag} and |\eqp@next@|\meta{tag} to |0pt|.
1597 % \begin{macrocode}
1598 \eqp@tempdima\csname eqp@this@#1\endcsname\relax
1599 \eqp@tempdimb\csname eqp@next@#1\endcsname\relax
1600 \ifdim\eqp@tempdima=\eqp@tempdimb
1601 \else
1602 \@latex@warning@no@line{Rerun to correct the width of eqparbox `#1'}%
1603 \fi
1604 \immediate\write\@auxout{%
1605 \string\expandafter\string\gdef\string\csname\space
1606 eqp@this@#1\string\endcsname{%
1607 \csname eqp@next@#1\endcsname
1608 }%
1609 ^^J%
1610 \string\expandafter\string\gdef\string\csname\space
1611 eqp@next@#1\string\endcsname{0pt}%
1612 }%
1613 % \end{macrocode}
1614 % Also make the |.aux| file define |\eqp@minwd@|\meta{tag} and
1615 % |\eqp@maxwd@|\meta{tag} to their current value, if any.
1616 % \begin{macrocode}
1617 \@ifundefined{eqp@minwd@#1}{}{%
1618 \immediate\write\@auxout{%
1619 \string\expandafter\string\gdef\string\csname\space
1620 eqp@minwd@#1\string\endcsname{%
1621 \csname eqp@minwd@#1\endcsname
1622 }%
1623 }%
1624 }%
1625 \@ifundefined{eqp@maxwd@#1}{}{%
1626 \immediate\write\@auxout{%
1627 \string\expandafter\string\gdef\string\csname\space
1628 eqp@maxwd@#1\string\endcsname{%
1629 \csname eqp@maxwd@#1\endcsname
1630 }%
1631 }%
1632 }%
1633 }%
1634 \eqp@taglist
1635 \endgroup
1636 % \end{macrocode}
1637 % We output a generic ``rerun |latex|'' message if we encountered a
1638 % tag that was not present on the previous run. (This is always the
1639 % case on the first run or the first run after deleting the
1640 % corresponding |.aux| file.
1641 % \begin{macrocode}
1642 \ifeqp@must@rerun
1643 \@latex@warning@no@line{Rerun to correct eqparbox widths}
1644 \fi
1645 }
1646 % \end{macrocode}
1647 % \end{macro}
1648 %
1649 % \Finale
1650 \endinput