Debian Codegraph @

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

raw
1 % \iffalse
2 %
3 % D O T S E Q N . D T X ver 1.1
4 %
5 % Copyright (C) 1995 by Donald Arseneau
6 % This file may be freely transmitted and reproduced, but it may
7 % not be changed unless the name is changed also (except that you
8 % may freely change the paper-size option for \documentclass).
9 % This notice must be left intact.
10 %
11 %<package>\NeedsTeXFormat{LaTeX2e}
12 %<*dtx>
13 \ProvidesFile{dotseqn.dtx}
14 %</dtx>
15 %<package>\ProvidesPackage{dotseqn}
16 %<driver>\ProvidesFile{dotseqn.drv}
17 [1995/03/22 v1.1 \space Dots leading to equation numbers]
18 %<*driver>
19 \makeatletter
20 \typein[\answer]{Do you want to generate dotseqn.sty? (Yes/No)}
21 \edef\answer{`\expandafter\@car\answer N\@nil}
22 \ifodd\answer
23 \begin{filecontents}{dotseqn.ins}
24 % dotseqn.ins: This is a temporary file. You can delete it.
25 \keepsilent
26 \preamble
27
28 D O T S E Q N . S T Y is Copyright (c) 1995 by Donald Arseneau
29
30 This file may be freely transmitted and reproduced, but it may not be
31 changed unless the name is changed also. This notice must remain intact.
32
33 \endpreamble
34 \generateFile{dotseqn.sty}{t}{\from{dotseqn.dtx}{package}}
35 \Msg{ }
36 \Msg{You should now copy dotseqn.sty to a directory where LaTeX checks for}
37 \Msg{input files. \space Run LaTeX again to generate documentation.}
38 \Msg{ }\endinput
39 \end{filecontents}
40 \makeatletter \closein\@inputcheck % because a bug in LaTeX
41 \def\batchfile{dotseqn.ins}
42 \csname fi\endcsname\input docstrip.tex % avoid unbalanced if
43 \fi
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 %
46 \documentclass{ltxdoc}
47 %
48 % \documentclass[a4paper]{ltxdoc}
49 %
50 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 \typeout{Generating user documentation for the dotseqn package.}
52 \typein[\answer]{Do you also want a commented source listing? (Yes/No)}
53 \edef\answer{`\expandafter\@car\answer N\@nil}
54 \ifodd\answer \else \OnlyDescription \fi
55 \DisableCrossrefs
56 \providecommand{\Lenv}[1]{\textsf{#1}}
57 \providecommand{\Lopt}[1]{\textsf{#1}}
58 \providecommand{\pkg}[1]{\texttt{#1}}
59 \setlength\hfuzz{2pt}
60 \begin{document}
61 \DocInput{dotseqn.dtx}
62 \end{document}
63 %</driver>
64 % \fi
65 % \CheckSum{211}
66 % \GetFileInfo{dotseqn.dtx}
67 % \renewcommand\baselinestretch{1.13}
68 % \title{DOTSEQN: Flush-left equations with dotted leaders to the
69 % equation number}
70 % \author{Donald Arseneau}
71 % \date{version \fileversion, revised \filedate}
72 % \maketitle
73 %
74 % \section{Introduction}
75 %
76 % The \Lopt{dotseqn} package provides a different format for typesetting
77 % equations, one reportedly used in `old style Britsh books'~-- equations
78 % aligned on the left, with dots on the right leading to the equation
79 % number. Like this
80 % \begin{itemize}
81 % \item[]$\displaystyle x = \frac{-b\pm\sqrt{b^2-4ac}}{2a}$\leaders
82 % \hbox{\kern4pt.\kern4pt}\hfill(1)
83 % \end{itemize}
84 % \iffalse
85 % ! Of course you should type equations normally!
86 % ! I cheated here so that this documentation could
87 % ! be printed *without* installing dotseqn.sty.
88 % \fi
89 % Equations without numbers have no leaders.
90 %
91 % This package behaves a lot like \Lopt{fleqn} (so that option is
92 % superfluous). In particular, the equations are not centered, but
93 % indented a constant distance from the left margin, controlled by
94 % \cs{mathindent}. The default indentation is the same as for lists.
95 %
96 % \section{Affected environments}
97 %
98 % Math environments with equation numbers, \Lenv{equation} and
99 % \Lenv{eqnarray}, are changed to produce left-justified equations,
100 % and to draw dotted leaders between the equation and the equation
101 % number. If there is no number, as specified by \cs{nonumber},
102 % then no leaders are drawn.
103 %
104 % Other math environments~-- \Lenv{displaymath}, \Lenv{eqnarray$*$},
105 % and |\[|~\dots\,|\]| -- do not produce equation numbers and therefore
106 % behave the same as they do under the \Lopt{fleqn} document option.
107 %
108 % \section{Options}
109 %
110 % This package is very similar to the \Lopt{fleqn} document class option,
111 % so specifying \Lopt{fleqn} is superfluous. The \Lopt{leqno} class
112 % option is forbidden because it is incompatible with the dotted style
113 % of equation labeling. (Where would the leaders go?)
114 % As is the case for the ordinary \Lopt{fleqn} option, the equation
115 % indentation is controlled by the length \cs{mathindent}, with a default
116 % indentation equal to the indentation of lists. It can be changed in
117 % the document preamble (with \cs{setlength}). Reasonable alternatives
118 % are zero (|0pt|) or the paragraph indentation (\cs{parindent}).
119 %
120 % The \pkg{dotseqn} package has two options of its own which can be
121 % specified with the \cs{usepackage} command. The \Lopt{leftjust} option
122 % causes the first column in \Lenv{eqnarray} and \Lenv{eqnarray$*$}
123 % to be flush left. Ordinarily, these pieces are flush right against
124 % the middle column.
125 %
126 % Another option is \Lopt{nocolsep}, which gets rid of that (ridiculous)
127 % extra space in the second column of \Lenv{eqnarray} equal to twice
128 % \cs{arraycolsep}. I would prefer to make \Lopt{nocolsep} the default,
129 % but it seems best that the normal behavior agrees with the usual
130 % documented behavior of \LaTeX.
131 %
132 % This typeset documentation was generated by running \LaTeX\ on
133 % |dotseqn.dtx|, and |dotseqn.sty| is generated the same way. This
134 % is my experiment with single-file |dtx| distribution.
135 %
136 % \StopEventually{}
137 %
138 % \section{The implementation}
139 %
140 % \iffalse
141 %<*package>
142 % \fi
143 %
144 % \begin{macro}{\EqnDots}
145 % The definitions here are based closely on the class option \Lopt{fleqn}.
146 % The principal difference is that dotted leaders are used to replace
147 % some horizontal filling commands. The leaders are given by the fairly
148 % typical \cs{leaders} command:
149 % \begin{macrocode}
150 \newcommand\EqnDots{\leaders\hbox{\kern4\p@ .\kern4\p@}\hfill}
151 % \end{macrocode}
152 % which can be changed by the intrepid document designer.
153 % \end{macro}
154 %
155 % \begin{macro}{\mathindent}
156 % Imitating the definitions for \pkg{fleqn}, we define a math indentation,
157 % but only if it is not defined already, and set the default indentation
158 % equal to the outer-level list indentation.
159 % \begin{macrocode}
160 \@ifundefined{mathindent}{\newdimen\mathindent \mathindent\leftmargini}{}
161 % \end{macrocode}
162 % The implementation in \pkg{fleqn.clo} is complicated by the need
163 % to delay assigning the default value to \cs{mathindent}, but that is
164 % not necessary here because packages like this are processed after the
165 % document class is fully declared.
166 % \end{macro}
167 % \begin{environment}{displaymath}
168 % \begin{macro}{\[}
169 % The environment \Lenv{displaymath}, alias |\[|~\dots\,|\]|, is
170 % identical with its definition in \pkg{fleqn.clo}. First the beginning
171 % \begin{macrocode}
172 \renewcommand{\[}{\relax \ifmmode\@badmath \else
173 \begin{trivlist}%
174 \@beginparpenalty\predisplaypenalty \@endparpenalty\postdisplaypenalty
175 \item[]\leavevmode \hbox to\linewidth\bgroup $\m@th\displaystyle %$
176 \hskip\mathindent\bgroup
177 \fi}
178 % \end{macrocode}
179 % \end{macro}
180 % \begin{macro}{\]}
181 % \dots and then the |\end{displaymath}| or |\]|
182 % \begin{macrocode}
183 \renewcommand{\]}{\relax\ifmmode \egroup $\hfil% $
184 \egroup \end{trivlist}%
185 \else \@badmath \fi}
186 % \end{macrocode}
187 % \end{macro}
188 % \end{environment}
189 %
190 % \begin{environment}{equation}
191 % The \Lenv{equation} environment begins exactly the same was as in
192 % \pkg{fleqn}, but it ends using \cs{EqnDots} in place of \cs{hfil}.
193 % \begin{macrocode}
194 \renewenvironment{equation}%
195 {\@beginparpenalty\predisplaypenalty \@endparpenalty\postdisplaypenalty
196 \refstepcounter{equation}\trivlist \item[]\leavevmode
197 \hbox to\linewidth\bgroup $\m@th% $
198 \displaystyle \hskip\mathindent}%
199 {$\EqnDots % $ Replace `\hfil' with dotted leaders `\EqnDots'.
200 \displaywidth\linewidth\hbox{\@eqnnum}\egroup \endtrivlist}
201 % \end{macrocode}
202 % The \Lenv{equation$*$} environment need not be redefined because it
203 % is defined in terms of \Lenv{equation}, and it has no equation number
204 % so it needs no \cs{EqnDots}.
205 % \end{environment}
206 %
207 % \begin{environment}{eqnarray}
208 % The \Lenv{eqnarray} environment has the most changes. In order to make
209 % the leaders fill the width, the space between the equation and the
210 % equation number must be part of a column entry; it cannot be filled by
211 % tabskip glue. Thus, this redefinition has one fewer column~-- there is
212 % no separate column for the equation number! This also necessitates
213 % a changed definition for |\\|, so see \cs{@@eqncr} below. As yet,
214 % \Lenv{eqnarray} is not described in detail in \pkg{classes.dtx}, but
215 % there are some useful comments in \pkg{ltmath.dtx}. They are reproduced
216 % here:
217 %
218 % \begin{quotation}
219 % To get a proper \cs{@currentlabel} we have to redefine it for the
220 % whole display. Note that we can't use \cs{refstepcounter} as this
221 % results in \cs{@currentlabel} getting [frozen at the beginning] and
222 % thus always writing the first label to the \texttt{.aux} file.
223 % Default is for left-hand side of equations to be flushright.
224 % To make them flushleft, |\let\@eqnsel = \hfil|
225 % [this is just what the \Lopt{leftjust} option does].
226 % \end{quotation}
227 %
228 % \noindent In further explanation, I should add that the counter
229 % \cs{@eqcnt} is globally set in each of the columns so that |\\|
230 % will know how many column separators (|&|) to insert before the
231 % equation number. This redefined version has only 3 alignment columns,
232 % so this insertion is modified (in \cs{@@eqncr}). In the third and
233 % final column, after the math material, there is a confusing
234 % |\hskip\@centering|. In fact, this has no effect when an
235 % equation number is present, because the \cs{EqnDots} are infinitely
236 % more stretchable, but the \cs{hskip} is left in place for the case
237 % of \cs{nonumber} which needs some filling.
238 %
239 % So, in the absence of tabskip glue, how is the equation forced out
240 % to the full line width? Using \ |\halign to\linewidth|' \ will not
241 % work because it only stretches \cs{tabskip} glue. The original
242 % \ |\halign to\linewidth| \ is retained only to give overfull box
243 % warnings when an alignment is too wide for the page. To stretch
244 % the third coulumn out to the full line width, a blank row is added
245 % at the end of the alignment by |\end{eqnarray}|, with a single entry
246 % spanning the full line width. This makes use of an often annoying
247 % behavior of \TeX: when multiple columns need to be enlarged to match
248 % a spanning entry, all the extra space is added to the final column.
249 % The extra `phantom' row uses a negative \cs{vskip} and a strut with
250 % a depth given by \cs{prevdepth} to simulate the depth of the expected
251 % last line in the equation array. A temporary macro is used to preserve
252 % the value of \cs{prevdepth} and use it after an end-of-group.
253 %
254 % A special command `\cs{DEQ@acs}' surrounds the entry for the second
255 % column. Ordinarily this gives |\hskip 2\arraycolsep|, but with the
256 % \Lopt{nocolsep} option it gives |\null| (like~|\mbox{}|), which produces
257 % the natural math-mode spacing around the entry.
258 % \begin{macrocode}
259 \renewenvironment{eqnarray}{%
260 \stepcounter{equation}%
261 \def\@currentlabel{\p@equation\theequation}%
262 \global\@eqnswtrue \m@th \global\@eqcnt\z@ \tabskip\mathindent
263 \let\\\@eqncr \setlength\abovedisplayskip\topsep
264 \ifvmode \addtolength\abovedisplayskip\partopsep \fi
265 \addtolength\abovedisplayskip\parskip
266 \setlength\belowdisplayskip\abovedisplayskip
267 \setlength\belowdisplayshortskip\abovedisplayskip
268 \setlength\abovedisplayshortskip\abovedisplayskip
269 $$\everycr{}\halign to\linewidth% $$
270 \bgroup
271 \hskip\@centering
272 $\displaystyle\tabskip\z@skip{##}$\@eqnsel&%
273 \global\@eqcnt\@ne \hfil${\DEQ@acs##\DEQ@acs}$\hfil&%
274 \global\@eqcnt\tw@ $\displaystyle{##}$\hskip\@centering\cr%
275 }% end of "\begin" part
276 {\@@eqncr
277 \noalign{% vertical skip up to overlay phantom line
278 \penalty\@M \vskip-\prevdepth
279 \edef\@tempa{\omit\span\omit\span\omit % span three columns
280 \vrule\@depth\the\prevdepth \@width\z@ % strut of proper depth
281 \kern-\mathindent \kern\linewidth}% % full line width
282 \nointerlineskip \expandafter % use saved |\@tempa| outside group
283 }\@tempa\cr
284 \egroup
285 \global\advance\c@equation\m@ne$$% $$
286 \global\@ignoretrue
287 }
288 % \end{macrocode}
289 % \end{environment}
290 %
291 % \begin{macro}{\@@eqncr}
292 % Now the \cs{@@eqncr} macro (alias |\\|) needs redefining. The
293 % number of inserted |&| separators is reduced, the warning is
294 % removed because it is quite proper to already be in the last column,
295 % and the placement of the equation number is changed: instead
296 % of letting the \cs{halign} template do the spacing, \cs{@@eqncr}
297 % leaves math mode, inserts the leaders, typesets the equation number
298 % (using \cs{@eqnnum}), then begins math mode again so things will
299 % balance when the template tries to end math. Note: \cs{reserved@a}
300 % is set to something innocuous before \cs{ifcase} just in case it
301 % was let equal to something like \cs{fi}.
302 % \begin{macrocode}
303 \def\@@eqncr{\let\reserved@a\@empty
304 \ifcase\@eqcnt \def\reserved@a{& &}\or \def\reserved@a{&}\fi
305 \reserved@a
306 \if@eqnsw \egroup $\EqnDots \@eqnnum $\bgroup \stepcounter{equation}%
307 \fi \global\@eqnswtrue\global\@eqcnt\z@\cr}
308 % \end{macrocode}
309 % \end{macro}
310 %
311 % Finally, we handle the package options \Lopt{leftjust} and
312 % \Lopt{nocolsep}. Declare the default behavior; declare the optional
313 % behavior, as described above; and process any options specified.
314 % \begin{macrocode}
315 \def\DEQ@acs{\hskip\tw@\arraycolsep}
316 \DeclareOption{leftjust}{\let\@eqnsel\hfil}
317 \DeclareOption{nocolsep}{\let\DEQ@acs\null}
318 \ProcessOptions
319 % \end{macrocode}
320 %
321 % \iffalse
322 %</package>
323 % \fi
324 %
325 % \Finale
326 \endinput