Debian Codegraph @

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

raw
1 % \iffalse meta-comment
2 %
3 % Copyright 1999-2026 Johannes L. Braams. All rights reserved.
4 %
5 % This file is part of the subeqn package.
6 % ----------------------------------------
7 %
8 % It may be distributed and/or modified under the
9 % conditions of the LaTeX Project Public License, either version 1.3c
10 % of this license or (at your option) any later version.
11 % The latest version of this license is in
12 % http://www.latex-project.org/lppl.txt
13 % and version 1.3c or later is part of all distributions of LaTeX
14 % version 2008 or later.
15 %
16 % This work has the LPPL maintenance status "maintained".
17 %
18 % The Current Maintainer of this work is Johannes Braams.
19 %
20 % The list of all files belonging to the supertabular package is
21 % given in the file `MANIFEST.
22 %
23 % The list of derived (unpacked) files belonging to the distribution
24 % and covered by LPPL is defined by the unpacking scripts (with
25 % extension .ins) which are part of the distribution.
26 % \fi
27 %
28 % \CheckSum{84}
29 % \iffalse
30 % Copyright (C) 1999-2026
31 % Donald Arsenau at reg.triumf.ca,
32 % Johannes Braams texniek at texniek.nl
33 %
34 %<*dtx>
35 \ProvidesFile{subeqn.dtx}
36 %</dtx>
37 %<package>\NeedsTeXFormat{LaTeX2e}[1998/06/01]
38 %<package>\ProvidesPackage{subeqn}
39 %<sample>\ProvidesFile{subeqn-sample.tex}
40 %<driver>\ProvidesFile{subeqn.drv}
41 %\ProvidesFile{subeqn.dtx}
42 [2026/01/02 v2.0d subnumbering of equations]
43 %<*driver>
44 \documentclass{ltxdoc}
45 \begin{document}
46 \pagestyle{myheadings}
47 \providecommand{\Lenv}[1]{\textsf{#1}}
48 \providecommand{\Lopt}[1]{\textsf{#1}}
49 \providecommand{\pkg}[1]{\texttt{#1}}
50 \providecommand{\file}[1]{\texttt{#1}}
51 \DocInput{subeqn.dtx}
52 \end{document}
53 %</driver>
54 % \fi
55 %
56 % \GetFileInfo{subeqn.dtx}
57 % \title{Subnumbering of equations\thanks{This file
58 % has version number \fileversion, last
59 % revised \filedate.}}
60 % \author{Donald Arsenau \and Johannes Braams}
61 % \date{\filedate}
62 % \maketitle
63 %
64 % \markboth
65 % {subeqn package version \fileversion\space as of \filedate}
66 % {subeqn package version \fileversion\space as of \filedate}
67 %
68 % \section{Introduction}
69 %
70 % Sometimes it is necessary to be able to refer to subexpressions
71 % of an equation. In order to do that these subexpressions should
72 % be numbered. In standard \LaTeX\ there is no provision for
73 % this. To solve this problem Stephen Gildea once wrote
74 % \file{subeqn.sty} for \LaTeX$\:$2.09; Donald Arsenau rewrote the
75 % macros and Johannes Braams made them available for \LaTeXe.
76 %
77 % Note that this package is \emph{not} compatible with the package
78 % \pkg{subeqnarray}, written by Johannes Braams.
79 %
80 % This package can be used together with the \LaTeX\ options
81 % \Lopt{leqno} and \Lopt{fleqn}.
82 %
83 % \section{Available environments}
84 %
85 % \DescribeEnv{subeqations} Inside the \Lenv{subeqations} environment
86 % \LaTeX's equation environments such as \Lenv{equation} and
87 % \Lenv{eqnarray} are numbered as subexpressions. At the same time
88 % the number of the (main) equation is kept the same.
89 %
90 % \DescribeEnv{subeqnarray} |\begin{subeqnarray}| works like
91 % |\begin{subequations}||\begin{eqnarray}|, but saves typing. A
92 % |\label| command given at the very beginning of the first entry
93 % defines a |label| for the overall equation number, as if you had
94 % typed |\begin{subequations}||\label{xxx}||\begin{eqnarray}|.
95 %
96 % \section{Available commands}
97 %
98 % \DescribeMacro{\thesubequation} The command |\thesubequation|
99 % controls the labelling of the subexpressions of an equation. You
100 % can change the labelling by redefining this command, but the
101 % names of the counters may be confusing: The sub-number is given
102 % by counter \texttt{equation}, while the overall equation number
103 % is given by \texttt{mainequation}.
104 %
105 % There are two ways to reference the overall equation number:
106 % through its value, as in |\Roman{mainequation}|, or through
107 % |\themainequation|, which gives the text of the normal
108 % |\theequation|. Refer to the local sub-number through the value
109 % of the \texttt{equation} counter, as in |\alph{equation}|.
110 % The default numbering is like 13c, given by:
111 %\begin{verbatim}
112 %\newcommand*{\thesubequation}{\themainequation\alph{equation}}
113 %\end{verbatim}
114 %
115 % Some alternatives:\\
116 % A number such as 13.C is achieved by
117 %\begin{verbatim}
118 % \newcommand*{\thesubequation}{\themainequation.\Alph{equation}}
119 %\end{verbatim}
120 % A number such as 13-iii is achieved by
121 %\begin{verbatim}
122 % \newcommand*{\thesubequation}{\themainequation-\roman{equation}}
123 % \newcommand*{\thesubequation}{\themainequation.\Alph{equation}}
124 %\end{verbatim}
125 % When the document class which is used has declared
126 %\begin{verbatim}
127 % \renewcommand{\@eqnnum}{\theequation}
128 % \renewcommand{\theequation}{(\arabic{equation})}
129 %\end{verbatim}
130 % which puts parentheses around \emph{all} equation numbers, including
131 % those produced by the |\ref| command, you can use:
132 %\begin{verbatim}
133 %\newcommand*{\thesubequation}{(\arabic{mainequation}\alph{equation})}
134 %\end{verbatim}
135 %
136 % \StopEventually{}
137 %
138 % \section{The implementation}
139 %
140 % \begin{macrocode}
141 %<*package>
142 % \end{macrocode}
143 %
144 % \begin{environment}{subeqations}
145 % Within the \Lenv{subequations} the equation numbers consist of
146 % two parts. The first part is a representation of the current value
147 % of the \texttt{equation} counter when the environment is entered,
148 % ie the number of the equation; the second part indicates the
149 % number of the subexpression of the equation.
150 % \begin{macrocode}
151 \newenvironment{subequations}{%
152 % \end{macrocode}
153 % First we update the \texttt{equation} counter,
154 % \begin{macrocode}
155 \refstepcounter{equation}%
156 % \end{macrocode}
157 % then we save its current value in |\c@mainequation| and define
158 % |\themainequation| to be the current representation of the
159 % \texttt{equation} counter.
160 % \begin{macrocode}
161 \mathchardef\c@mainequation\c@equation
162 \protected@edef\themainequation{\theequation}%
163 % \end{macrocode}
164 % Then we change the representation of the \texttt{equation}
165 % counter to represent the subexpression number. Finally we set the
166 % \texttt{equation} counter to zero as we use it for counting the
167 % subexpressions.
168 % \begin{macrocode}
169 \let\theequation\thesubequation
170 \global\c@equation\z@
171 }{%
172 % \end{macrocode}
173 % When the environment is finished we restore the value of the
174 % \texttt{equation} counter.
175 % \begin{macrocode}
176 \global\c@equation\c@mainequation
177 \global\@ignoretrue
178 }
179 % \end{macrocode}
180 % \end{environment}
181 %
182 % \begin{macro}{\thesubequation}
183 % By default the subexpressions will be numbered with lower case
184 % letters. The representation of the \texttt{equation} counter also
185 % includes the saved value of the \texttt{equation} counter. This
186 % can be changed by redefining this command.
187 % \begin{macrocode}
188 \newcommand{\thesubequation}{\themainequation\alph{equation}}
189 % \end{macrocode}
190 % \end{macro}
191 %
192 % \begin{environment}{subeqnarray}
193 %
194 % \begin{macrocode}
195 \newenvironment{subeqnarray}{%
196 \subequations
197 \@ifnextchar\label{\@lab@subeqnarray}{\eqnarray}
198 }{%
199 \endeqnarray\endsubequations
200 }
201 % \end{macrocode}
202 % \end{environment}
203 %
204 % \begin{macro}{\@lab@subeqnarray}
205 % This macro picks up the |\label| command and its argument and
206 % re-inserts it \emph{before} starting the \Lenv{eqnarray}
207 % environment.
208 % \begin{macrocode}
209 \newcommand*{\@lab@subeqnarray}[2]{#1{#2}\eqnarray}
210 % \end{macrocode}
211 % \end{macro}
212 %
213 % \begin{macrocode}
214 %</package>
215 % \end{macrocode}
216 %
217 % \section{An example of the use of this package}
218 %
219 % When you run the following document through \LaTeX\ you will see
220 % the differene between the \texttt{subeqnarray} and
221 % \texttt{eqnarray} environments.
222 % \begin{macrocode}
223 %<*sample>
224 \documentclass{article}
225 \usepackage{subeqn}
226
227 \begin{document}
228 \title{Sample sub-equations}
229 \author{Johannes L. Braams}
230 \date{\today}
231 \maketitle
232
233 \noindent
234 This is an example of the use of the \texttt{subeqations}
235 package. First we have a normal \textsf{equation} environment.
236 \begin{equation}
237 \label{a}
238 a^2 + b^2 = c^2
239 \end{equation}
240 Now we start sub-numbering.
241 \begin{subequations}
242 \label{b}
243 \begin{equation}
244 \label{b1}
245 d^2 + e^2 = f^2
246 \end{equation}
247 We can refer to equation~\ref{a}, \ref{b} and~\ref{b1}.
248 \begin{equation}
249 \label{b2}
250 g^2 + h^2 = i^2
251 \end{equation}
252 This was equation~\ref{b2}.
253 \begin{eqnarray}
254 \label{c}
255 x &=& y+z\label{c1}\\
256 u &=& v+w\label{c2}
257 \end{eqnarray}
258 This was expression~\ref{c}, consisting of parts~\ref{c1}
259 and~\ref{c2}.
260 \end{subequations}
261
262 \noindent
263 Now lets start a \textsf{subeqnarray} environment.
264 \begin{subeqnarray}
265 \label{d}
266 x &=& y+z\label{d1}\\
267 u &=& v+w\label{d2}
268 \end{subeqnarray}
269 This was equation~\ref{d}, with parts~\ref{d1} and~\ref{d2}.
270 \end{document}
271 %</sample>
272 % \end{macrocode}
273 %
274 % \Finale
275 \endinput