texlive[53909] Master/texmf-dist: cases (25feb20)

commits+karl at tug.org commits+karl at tug.org
Tue Feb 25 23:02:09 CET 2020


Revision: 53909
          http://tug.org/svn/texlive?view=revision&revision=53909
Author:   karl
Date:     2020-02-25 23:02:08 +0100 (Tue, 25 Feb 2020)
Log Message:
-----------
cases (25feb20)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/cases/cases.pdf
    trunk/Master/texmf-dist/doc/latex/cases/cases.tex
    trunk/Master/texmf-dist/tex/latex/cases/cases.sty

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/cases/README

Added: trunk/Master/texmf-dist/doc/latex/cases/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/cases/README	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/cases/README	2020-02-25 22:02:08 UTC (rev 53909)
@@ -0,0 +1,14 @@
+cases.sty version 3.0 2020/02/22
+
+Copyright 1993, 1994, 1995, 2000, 2002, 2020 by Donald Arseneau,
+asnd at triumf.ca, Vancouver, Canada.
+These macros may be freely transmitted, reproduced, or modified 
+provided that this notice is left intact.  Sub-equation numbering
+is based on subeqn.sty by Stephen Gildea; parts are based on LaTeX's
+eqnarray by Leslie Lamport and the LaTeX3 team; and some on
+amsmath.sty by the American Mathematical Society.
+
+This package provides a LaTeX environment "numcases" to produce
+multi-case equations with a separate equation number for each case.
+There is also a "subnumcases" environment which numbers each case
+with the overall equation number plus a letter [8a, 8b, etc.].


Property changes on: trunk/Master/texmf-dist/doc/latex/cases/README
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/latex/cases/cases.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/cases/cases.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/cases/cases.tex	2020-02-25 22:01:49 UTC (rev 53908)
+++ trunk/Master/texmf-dist/doc/latex/cases/cases.tex	2020-02-25 22:02:08 UTC (rev 53909)
@@ -1,6 +1,5 @@
 \documentclass[DIV=9, pagesize=auto]{scrartcl}
 
-\usepackage{fixltx2e}
 \usepackage{lmodern}
 \usepackage[T1]{fontenc}
 \usepackage{textcomp}
@@ -7,13 +6,12 @@
 \usepackage{amsmath}
 \usepackage{cases}
 \usepackage{microtype}
-\usepackage{hyperref}
-
+\usepackage{shortvrb}
+\usepackage[colorlinks]{hyperref}
+\MakeShortVerb"
+\newcommand*\kp[1]{\kern#1pt}
 \newcommand*{\fancybreak}{%
-  \par
-  \nopagebreak\medskip\nopagebreak
-  \noindent\null\hfill$*\quad*\quad*\quad$\hfill\null\par
-  \nopagebreak\medskip\pagebreak[0]%
+  \par \medbreak \vspace{0pt plus 1cm}\penalty 500 \vspace{0pt plus -1cm}%
 }
 \newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}}
 \newcommand*{\pkg}[1]{\textsf{#1}}
@@ -20,12 +18,14 @@
 \newcommand*{\cmd}[1]{\texttt{\string#1}}
 \newcommand*{\env}[1]{\texttt{#1}}
 \newcommand*{\meta}[1]{\textlangle\textsl{#1}\textrangle}
+\newcommand*{\opt}[1]{\texttt{[#1]}}
 
-\addtokomafont{title}{\rmfamily}
+%\addtokomafont{title}{\rmfamily}
 
-\title{The \pkg{cases} package\thanks{This manual corresponds to \pkg{cases}~v2.5, dated~May 2002.}}
+\title{The \pkg{cases} package%
+  \textnormal{\thanks{~~This manual corresponds to \pkg{cases}~v3.0, dated 2020/02/22.}}}
 \author{Donald Arseneau\\\mail{asnd at triumf.ca}}
-\date{May 2002}
+\date{Feb 2020}
 
 
 \begin{document}
@@ -32,117 +32,179 @@
 
 \maketitle
 
-\begingroup
-\small
+\begin{small}
 \noindent
-Copyright \textcopyright~1993, 1994, 1995, 2000, 2002 by Donald Arseneau, \mail{asnd at triumf.ca}.
+Copyright \textcopyright~1993, 1994, 1995, 2000, 2002, 2020 by Donald Arseneau, \mail{asnd at triumf.ca}.
 These macros may be freely transmitted, reproduced, or modified 
 provided that this notice is left intact.  Sub-equation numbering
-is based on \pkg{subeqn.sty} by Stephen Gildea; most of the rest is based
-on \LaTeX's \cmd{\eqnarray} by Leslie Lamport and the \LaTeX3 team.
+is based on \pkg{subeqn.sty} by Stephen Gildea; parts are based
+on \LaTeX's \env{eqnarray} by Leslie Lamport and the \LaTeX3 team;
+and some on amsmath.sty by the American Mathematical Society.
 \par
-\endgroup
+\end{small}
 
-\fancybreak
+\section*{Description}
 
-This provides a \LaTeX\ environment \verb+{numcases}+ to produce multi-case 
-equations with a separate equation number for each case.  There is
-also \verb+{subnumcases}+ which numbers each case with the overall equation
+The \pkg{cases} package provides a \LaTeX\ environment \env{numcases} to produce 
+multi-case equations with a separate equation number for each case.  There is
+also \env{subnumcases} which numbers each case with the overall equation
 number plus a letter [8a, 8b, etc.].   The syntax is
 %
-\begin{verbatim}
-\begin{numcases}{left_side}
-  case_1 & explanation_1 \\
-  case_2 & explanation_2 \\
-  ...
-  case_n & explanation_n
-\end{numcases}
-\end{verbatim}
+\begin{flushleft}
+"\begin{numcases}{"~\meta{left side}~"}"\\
+\quad  \meta{case 1\kp1} "&" \meta{explanation 1\kp1} "\\" \\
+\quad  \meta{case 2\kp2} "&" \meta{explanation 2\kp2} "\\" \\
+\quad  .~.~.\\
+\quad  \meta{case $n$} "&" \meta{explanation $n$} \\
+"\end{numcases}"
+\end{flushleft}
 %
-Each \meta{case} is a math formula, and each \meta{explanation} is a piece of lr mode
-text (which may contain math mode in \verb+\(...\)+ or \verb+$...$+).  The explanations
+Each \meta{case} is a math formula, to be typeset in display-math mode, like
+in a regular numbered equation. Each \meta{explanation} is a piece of lr-mode
+text (which may contain math mode in "\("\,\dots"\)" or "$"\,\dots"$").  The explanations
 are optional.  Equation numbers are inserted automatically, just as for
 the \env{eqnarray} environment.  In particular, the \cmd{\nonumber} command suppresses
 an equation number and the \cmd{\label} command allows reference to a particular 
-case.  In a \env{subnumcases} environment, a \cmd{\label} in the \meta{left\_side} of the 
+case. In a \env{subnumcases} environment, a \cmd{\label} in the \meta{left side} of the 
 equation gives the overall equation number, without any letter. 
 
 To use this package, 
-include  ``\verb+\usepackage{cases}+''  after ``\cmd{\documentclass}''.  You may also
-specify  ``\verb+\usepackage[subnum]{cases}+''  to force \emph{all} \env{numcases}
-environments to be treated as \env{subnumcases}.
+include "\usepackage{cases}"  after \cmd{\documentclass}, and also after 
+"\usepackage{amsmath}" if you are using that.
 
-\emph{Question:} Is there a \verb+{numcases*}+ environment for
+\fancybreak
+
+\noindent \emph{Question:} Is there a \env{numcases*} environment for
 unnumbered cases?\\
-\emph{Answer:} There is a \verb+{cases}+
-environment in \AmS-\LaTeX, but it is just as convenient to stick
-with the canonical \LaTeX\ array:
-% 
-\begin{verbatim}
-\[ left side = \left\{ \begin{array}...\end{array} \right. \]
-\end{verbatim}
-% 
-Speaking of \pkg{\AmS-math}, they use an entirely different system
-of equation numbering, and this package uses ordinary \LaTeX\ %
-numbering.
+\emph{Answer:} That would have the natural name \env{cases}, and it is 
+provided by \AmS-\LaTeX\ (\pkg{amsmath} package), or by this package given 
+the \opt{cases} option. It can also be achieved by using an ordinary \LaTeX\ array 
+between `"\left\lbrace\ "' and `"\right."'.
 
-\fancybreak
+Speaking of \pkg{amsmath} and package options, there are differences between the 
+style used for this package and the cases done by \pkg{amsmath} (see below), but cases.sty
+has options to increase compatibility.  Here is the full list of options for 
+this package.
+\begin{description}
+\item[\opt{subnum}] Force all \env{numcases} environments to be treated as 
+    \env{subnumcases}.
+\item[\opt{amsstyle}] For compatibility with \pkg{amsmath}'s \env{cases}, make \env{numcases}
+    use cramped math style ("\textstyle"), and put explanations in the same math style.
+\item[\opt{casesstyle}] Change \pkg{amsmath}'s \env{cases} environment to work in the text/math style
+    of \env{numcases}.
+\item[\opt{cases}] Define a \env{cases} environment for use without \pkg{amsmath}. (This 
+    is actually the same as the \opt{casesstyle} option.)
+\item[\opt{fleqn}] Flush-left equation alignment, indented by \cmd{\mathindent}
+    or \cmd{\mathmargin}. (Usually inherited from the \cmd{\documentclass} options.)
+\item[\opt{leqno}] Left-side equation numbering (usually inherited from the \cmd{\documentclass}
+    options). This looks silly with numbered cases!
+\end{description}
 
-\noindent
+\section*{Examples}
+
 A simple example is:
 %
 \begin{verbatim}
-\begin{numcases}{|x|=}
-  x, & for $x \geq 0$\\
-  -x, & for $x < 0$
-\end{numcases}
+     \begin{numcases} {|x|=}
+       x, & for $x \geq 0$\\
+       -x, & for $x < 0$
+     \end{numcases}
 \end{verbatim}
 %
 Giving:
 %
-\begin{numcases}{|x|=}
+\begin{numcases} {|x|=}
   x, & for $x \geq 0$\\
   -x, & for $x < 0$
 \end{numcases}
 
 \fancybreak
-
 \noindent
-Another example is calculating the square root of $c+id$. First compute
-\phantomsection
-\begin{subnumcases}{\label{w} w\equiv}
-  0    & $c = d = 0$\label{wzero}\\
-  \sqrt{|c|}\,\sqrt{\frac{1 + \sqrt{1+(d/c)^2}}{2}}   & $|c| \geq |d|$ \\
-  \sqrt{|d|}\,\sqrt{\frac{|c/d| + \sqrt{1+(c/d)^2}}{2}}   & $|c| < |d|$
+Another example, employing sub-numbering, is calculating the square root 
+of a complex number $c+id$. First compute
+\begin{subnumcases} {\label{weqn} w\equiv}
+  0       & for $c = d = 0$\label{wzero}\\
+  \sqrt{|c|}\,\sqrt{\frac{1 + \sqrt{1+(d/c)^2}}{2}} & for $|c| \geq |d|$ \\
+  \sqrt{|d|}\,\sqrt{\frac{|c/d| + \sqrt{1+(c/d)^2}}{2}} & for $|c| < |d|$
 \end{subnumcases}
-Then, using $w$ from eq.~(\ref{w}), the square root is
-\begin{subnumcases}{\sqrt{c+id}=}
-  0                    & $w=0$ (case \ref{wzero})\\
-  w+i\frac{d}{2w}      & $w \neq 0$, $c \geq 0$ \\
-  \frac{|d|}{2w} + iw  & $w \neq 0$, $c < 0$, $d \geq 0$ \\
-  \frac{|d|}{2w} - iw  & $w \neq 0$, $c < 0$, $d < 0$ 
+Then, using $w$ from eq.~(\ref{weqn}), the square root is
+\begin{subnumcases}{\label{sqrteqn} \sqrt{c+id}=}
+  0\,,              \label{aaa}   & $w=0$ (case \ref{wzero})\\
+  w+i\frac{d}{2w}\,,   & $w \neq 0$, $c \geq 0$ \\
+  \frac{|d|}{2w} + iw\,, & $w \neq 0$, $c < 0$, $d \geq 0$ \\
+  \frac{|d|}{2w} - iw\,,\label{ddd} & $w \neq 0$, $c < 0$, $d < 0$ 
 \end{subnumcases}
-
-\pagebreak[2]
-
-\noindent
-This was produced by:
-%
-\small
+These equations, eq.~(\ref{weqn}) and (\ref{sqrteqn}), were produced by:
+\begin{small}
 \begin{verbatim}
-Another example is calculating the square root of $c+id$. First compute
-\begin{subnumcases}{\label{w} w\equiv}
- 0    & $c = d = 0$\label{wzero}\\
-\sqrt{|c|}\,\sqrt{\frac{1 + \sqrt{1+(d/c)^2}}{2}}   & $|c| \geq |d|$ \\
-\sqrt{|d|}\,\sqrt{\frac{|c/d| + \sqrt{1+(c/d)^2}}{2}}   & $|c| < |d|$
+Another example, employing sub-numbering, is calculating the square root 
+of a complex number $c+id$. First compute
+\begin{subnumcases} {\label{weqn} w\equiv}
+  0       & for $c = d = 0$\label{wzero}\\
+  \sqrt{|c|}\,\sqrt{\frac{1 + \sqrt{1+(d/c)^2}}{2}} & for $|c| \geq |d|$ \\
+  \sqrt{|d|}\,\sqrt{\frac{|c/d| + \sqrt{1+(c/d)^2}}{2}} & for $|c| < |d|$
 \end{subnumcases}
-Then, using $w$ from eq.~(\ref{w}), the square root is
-\begin{subnumcases}{\sqrt{c+id}=}
-0                    & $w=0$ (case \ref{wzero})\\
-w+i\frac{d}{2w}      & $w \neq 0$, $c \geq 0$ \\
-\frac{|d|}{2w} + iw  & $w \neq 0$, $c < 0$, $d \geq 0$ \\
-\frac{|d|}{2w} - iw  & $w \neq 0$, $c < 0$, $d < 0$ 
+Then, using $w$ from eq.~(\ref{weqn}), the square root is
+\begin{subnumcases}{\label{sqrteqn} \sqrt{c+id}=}
+  0\,,                 & $w=0$ (case \ref{wzero})\\
+  w+i\frac{d}{2w}\,,   & $w \neq 0$, $c \geq 0$ \\
+  \frac{|d|}{2w} + iw\,, & $w \neq 0$, $c < 0$, $d \geq 0$ \\
+  \frac{|d|}{2w} - iw\,, & $w \neq 0$, $c < 0$, $d < 0$ 
 \end{subnumcases}
 \end{verbatim}
+\end{small}
 
+\section*{Compatibilibility with amsmath}
+
+When used in conjunction with amsmath.sty, the cases package will obey the the variant 
+commands \cmd{\tag}, \cmd{\notag}, and \cmd{\mathmargin}, however the formatting details
+differ between \pkg{amsmath}'s \env{cases} environment and \env{numcases}.
+For comparison, equation~(\ref{weqn}) formatted by \pkg{amsmath} and its \env{cases} environment
+may be  entered as
+\begin{flushleft}\small
+\begin{verbatim}
+\begin{equation}
+\label{wams} w \equiv
+\begin{cases}
+ 0    & \text{for}\ c = d = 0\\
+ \sqrt{|c|}\,\sqrt{\frac{1+\sqrt{1+(d/c)^2}}{2}} &\text{for}\ |c| \geq |d|\\
+ \sqrt{|d|}\,\sqrt{\frac{|c/d| + \sqrt{1+(c/d)^2}}{2}} &\text{for}\ |c|<|d|
+\end{cases}
+\end{equation}
+\end{verbatim}
+\end{flushleft}
+which produces
+\begin{equation}
+\label{wams} w\equiv
+\begin{cases}
+  0    & \text{for }c = d = 0\\
+  \sqrt{|c|}\,\sqrt{\frac{1+\sqrt{1+(d/c)^2}}{2}} & \text{for}\ |c| \geq |d| \\
+  \sqrt{|d|}\,\sqrt{\frac{|c/d| + \sqrt{1+(c/d)^2}}{2}} & \text{for}\ |c| < |d|
+\end{cases}
+\end{equation}
+To get this more compact layout with \env{numcases} you can insert "\textstyle" 
+at the beginning of each case, as needed, or use the \pkg{cases} 
+package option \opt{amsstyle}. 
+To have  the \env{cases} environment give the more open layout of eq.~(\ref{weqn}) 
+you can put "\displaystyle" at the beginning of each case, or use the  
+option \opt{casesstyle} for the \pkg{cases} package. (Yes these go with the cases package, they
+are not options for amsmath.)
+
+For full disclosure, even without any relevant package options, cases.sty will 
+slightly adjust the \env{cases} environment from \pkg{amsmath}, by adding a little
+space after the left brace.
+
+\section*{Sub-numbering}
+For control of the sub-equation-numbering style, see the
+\AmS-\LaTeX\ documentation for \env{subequations}, currently 
+in section 3.11.3. If you are not using amsmath, that documentation
+still mostly applies, except the name for regular equation numbers
+is then `mainequation' instead of `parentequation'. Also, the
+sub-numbering style can be controlled more easily by defining
+\cmd{\thesubequation}. An example for capitalized letters is
+\begin{verbatim}
+\renewcommand\thesubequation{\themainequation.\Alph{equation}} % 13.C
+\end{verbatim}
+
+
 \end{document}

Modified: trunk/Master/texmf-dist/tex/latex/cases/cases.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/cases/cases.sty	2020-02-25 22:01:49 UTC (rev 53908)
+++ trunk/Master/texmf-dist/tex/latex/cases/cases.sty	2020-02-25 22:02:08 UTC (rev 53909)
@@ -1,11 +1,12 @@
-%  C A S E S . S T Y             ver 2.5    May 2002
+%  C A S E S . S T Y             ver 3.0    Feb 2020
 %
-%  Copyright (C) 1993,1994,1995,2000,2002 by Donald Arseneau
+%  Copyright (C) 1993,1994,1995,2000,2002,2020 by Donald Arseneau
 %                                       asnd at triumf.ca
 %  These macros may be freely transmitted, reproduced, or modified 
 %  provided that this notice is left intact.  Sub-equation numbering
 %  is based on subeqn.sty by Stephen Gildea; most of the rest is based
-%  on LaTeX's \eqnarray by Leslie Lamport and the LaTeX3 team.
+%  on LaTeX's \eqnarray by Leslie Lamport and the LaTeX3 team,
+%  and parts of amsmath.sty by the American Mathematical Society.
 %
 %  This provides a LaTeX environment {numcases} to produce multi-case 
 %  equations with a separate equation number for each case.  There is
@@ -27,96 +28,111 @@
 %  case.  In a subnumcases environment, a \label in the left_side of the 
 %  equation gives the overall equation number, without any letter. 
 %
-%  To use this package, 
-%  include  "\usepackage{cases}"  after \documentclass.  You may also
-%  specify  "\usepackage[subnum]{cases}"  to force *all* numcases 
-%  environments to be treated as subnumcases.
-%
-%  Question: Is there a {numcases*} environment for unnumbered cases?
-%  Answer: There is a {cases} environment in AMS-LaTeX, but it is just as
-%  convenient to stick with the canonical LaTeX array:
-%  \[ left side = \left\{ \begin{array}...\end{array} \right. \]
-%
-%  Speaking of AMS-math, they use an entirely different system of equation
-%  numbering, and this package uses ordinary LaTeX numbering.
-%
-% - - - - - 
-%  A simple example is:
-%    \begin{numcases}{|x|=}
-%    x, & for $x \geq 0$\\
-%    -x, & for $x < 0$
-%    \end{numcases}
-%
-%  Giving:
-%                    / x   for x > 0              (1)
-%             |x| = <            -
-%                    \ -x  for x < 0              (2)
-% 
-% - - - - -   
-%
-% Another example is calculating the square root of $c+id$. First compute
-% \begin{subnumcases}{\label{w} w\equiv}
-%  0    & $c = d = 0$\label{wzero}\\
-% \sqrt{|c|}\,\sqrt{\frac{1 + \sqrt{1+(d/c)^2}}{2}}   & $|c| \geq |d|$ \\
-% \sqrt{|d|}\,\sqrt{\frac{|c/d| + \sqrt{1+(c/d)^2}}{2}}   & $|c| < |d|$
-% \end{subnumcases}
-% Then, using $w$ from eq.~(\ref{w}), the square root is
-% \begin{subnumcases}{\sqrt{c+id}=}
-% 0                    & $w=0$ (case \ref{wzero})\\
-% w+i\frac{d}{2w}      & $w \neq 0$, $c \geq 0$ \\
-% \frac{|d|}{2w} + iw  & $w \neq 0$, $c < 0$, $d \geq 0$ \\
-% \frac{|d|}{2w} - iw  & $w \neq 0$, $c < 0$, $d < 0$ 
-% \end{subnumcases}     
-%
-%  - - -  begin definitions - - - 
+%  For detailed description and package options, see cases.pdf (cases.tex).
  
-\ProvidesPackage{cases}[2002/05/02 ver 2.5 ]
+\ProvidesPackage{cases}[2020/02/22 ver 3.0]
 
+\newdimen\numc at numwid
+
+% copy \@@eqncr but change error message and handle \tag{} for amsmath:
+\def\@@numc at cr{\let\reserved at a\relax
+    \ifcase\@eqcnt \def\reserved at a{& & &}\or \def\reserved at a{& &}%
+     \or \def\reserved at a{&}\else
+       \let\reserved at a\@empty
+       \@latex at error{Too many columns in numcases environment}\@ehc\fi
+     \reserved at a \if at eqnsw\@eqnnum\stepcounter{equation}\else \iftag@ \df at tag\fi\fi
+     \global\@eqnswtrue\global\@eqcnt\z@\cr}
+
+\let\iftag@=\iffalse
+
 \newenvironment{numcases}[1]%
-{$$\numc at opts \setbox\z@\hbox
-  {\advance\c at equation\@ne\def\@currentlabel{\p at equation\theequation}% local
-  $\displaystyle {#1\null}\m at th$}%
- \numc at setsub 
+{$$\numc at opts
+ \refstepcounter{equation}% Needed for LHS \label
+ \setbox\z@\hbox {% typeset LHS
+   \def\@currentlabel{\p at equation\theequation}% local def
+   $\displaystyle {#1{}}\m at th$}%
+ \numc at setsub % maybe \subequations (handling \refstepcounter)
+ \def\@currentlabel{\p at equation\theequation}%
+ \global\@eqnswtrue\m at th
+ \def\tag##1{\def\@currentlabel{##1}\tag at in@align{##1}}%
+ \settowidth{\numc at numwid}{\ \advance\c at equation\tw@\numc at eqnnum}%
+ \@tempskipb\@centering
+ \ifx\numc at left\mathindent % fleqn:
+    \@tempskipa=\@ne\mathindent\@minus\@ne\mathindent
+    \ifx\numc at forcenumwid\z@ % leqno
+       \ifdim \numc at numwid>\mathindent % enlarge left space for equation number 
+         \@tempskipa=\numc at numwid\@minus\numc at numwid
+    \fi\fi
+ \else % not fleqn:
+    \@tempskipa=\@centering
+    \advance\@tempskipa \numc at numwid\@minus\numc at numwid
+    \advance\@tempskipa \numc at numwid\@minus\numc at forcenumwid
+    \advance\@tempskipb \tw@\numc at numwid\@minus\tw@\numc at numwid
+    \advance\@tempskipb -\numc at forcenumwid\@minus-\numc at forcenumwid
+ \fi
  \setbox\tw@\vbox\bgroup
-  \stepcounter{equation}\def\@currentlabel{\p at equation\theequation}% 
-  \global\@eqnswtrue\m at th \everycr{}\tabskip\numc at left\let\\\@eqncr
-  \halign to\dimen at ii \bgroup \kern\wd\z@ \kern14\p@ % assume width of brace
-    \tabskip\z at skip \global\@eqcnt\@ne $\displaystyle{##}$\hfil 
-   &\global\@eqcnt\tw@ \skip at 10\p@ \advance\skip@\tw@\arraycolsep \hskip\skip@
-    ##\unskip\hfil\tabskip\@centering% \unskip removes space if no explanations
-   &\global\@eqcnt\thr@@\hbox to\z@\bgroup\hss##\egroup\tabskip\z at skip\cr
-}{\@@eqncr \egroup % end \halign, which does not contain first column or brace
- \global\advance\c at equation\m at ne 
-%Measure the natural width of the alignment
- \unskip\unpenalty\unskip\unpenalty \setbox\z@\lastbox % grab last line
- \nointerlineskip \copy\z@ % then put it back
- \global\dimen at i\wd\z@ 
- \setbox\z@\hbox{\hskip-\numc at left\unhbox\z@}% Measure its natural width
- \ifdim \wd\z@<\dimen at i \global\dimen at i\wd\z@ \fi
-\egroup% end \vbox (box\tw@, box\z@ is restored to LHS)
-\hbox to\dimen at ii{\m at th % assemble the whole equation
-  \hskip\numc at left 
-  \hbox to\dimen at i{$\displaystyle \box\z@ % parameter #1
+  \everycr{}\let\\\@eqncr \let\@@eqncr\@@numc at cr
+  \tabskip\@tempskipa
+  \halign to\dimen at ii \bgroup % white space for LHS followed by RHS
+    \kern\wd\z@ \kern10\p@ % assume width of brace
+    \global\let\iftag@=\iffalse % for amsmath (make sure this is not in if block)
+    \global\@eqcnt\@ne $\numc at dispstyle{##}$\hfil 
+    \tabskip\z at skip &% explanation
+    \global\@eqcnt\tw@
+    \numc at expstyle\quad ##\unskip\numc at expstyle\hfil % \unskip removes quad if no explanation
+    \tabskip\@tempskipb &% equation number
+    \global\@eqcnt\thr@@\hbox to\numc at forcenumwid\bgroup\hss##\egroup
+    \tabskip\z at skip\cr
+}{%
+    \@@numc at cr \egroup % end \halign, which does not contain first column or brace
+  \global\advance\c at equation\m at ne 
+  % Measure the natural width of the alignment
+  \unskip\unpenalty\unskip\unpenalty \setbox\z@\lastbox % grab last line
+  \nointerlineskip \copy\z@ % then put it back
+  \global\dimen at i\wd\z@ 
+  \setbox\z@\hbox{\unhbox\z@}% Measure its natural width in \dimen at i
+  \global\dimen at i\wd\z@
+ \egroup% end \vbox (\tw@) box\z@ is restored to LHS; \dimen at i is retained
+ \advance\dimen at i-\@tempskipa \advance\dimen at i-\wd\z@ \advance\dimen at i-10\p@ 
+ \advance\dimen at i-\@tempskipb 
+ % now \@dimen at i is natural width of RHS + explanation + eqno columns
+ \hbox to\wd\tw@{\m at th % assemble the whole equation stretched to display width
+  \hskip\@tempskipa
+  \box\z@ % LHS - parameter #1
+  \hbox to10\p@{\hss$\displaystyle
     \dimen@\ht\tw@ \advance\dimen@\dp\tw@ % get size of brace
-    \left\{\vcenter to\dimen@{\vfil}\right.\n at space % make brace
-    $\hfil}\hskip\@centering % finished first part (filled whole line)
-  \kern-\dimen at ii % backspace the full width
-  $\vcenter{\box\tw@}$% overlay the alignment
- }% end the \hbox to\dimen at ii
+    \ifdim\dimen@<1.5em\dimen@=1.5em\fi % don't allow really small brace
+    \left\lbrace\vcenter to\dimen@{\vfil}\,\right.\n at space % make brace
+    $\hss}% end 10pt brace box
+  \kern\dimen at i
+  \hskip\@tempskipb
+ }% finished first part (filled whole line) end the \hbox to\wd\tw@
+ \kern-\wd\tw@ % backspace the full width
+ \vcenter{\box\tw@}% overlay the alignment
 \numc at resetsub
 $$\global\@ignoretrue}
 
+% a wrapper around \subequations so it works in cases with hyperref and amsmath
+\def\numc at subequations{% skip the \refstepcounter inside \subequations
+  \let\numc at opts\refstepcounter
+  \def\refstepcounter##1{\let\refstepcounter\numc at opts}%
+  \subequations
+  \refstepcounter{equation}}
+
 \let\numc at setsub\relax
 \let\numc at resetsub\relax
 
-\def\subnumcases{\let\numc at setsub\subequations 
-   \let\numc at resetsub\endsubequations  \numcases}
+\def\subnumcases{%
+  \let\numc at setsub\numc at subequations 
+  \let\numc at resetsub\endsubequations
+  \numcases}
 \let\endsubnumcases\endnumcases 
 
 % declare subequations -- either defining them following the style of
-% Gildea's subeqn.sty, or using the syntax of AMS-LaTeX if that is loaded.
+% Gildea's subeqn.sty, or using the version from AMS-LaTeX if that is loaded.
 
-\@ifundefined{c at parentequation}{% No AMS, define subequations from scratch:
+\@ifundefined{c at parentequation}{% No AMS
+\def\numc at eqnnum{\@eqnnum}
 %
 % These versions of subequations follow the style of Gildea's subeqn.sty,
 % but are thoroughly rewritten.  
@@ -163,22 +179,83 @@
 \def\@lab at subeqnarray#1#2{\begingroup 
   \let\@currentlabel\themainequation #1{#2}\endgroup}
 %
-}{}% AMS \subequations already defined 
+}{% AMS
 
+%  \subequations already defined;
+% use tag format
+\def\numc at eqnnum{\tagform@{\theequation}}    
+% add little space after brace to amsmath's cases
+
+\def\@tempa{%
+  \let\@ifnextchar\new at ifnextchar
+  \left\lbrace
+  \def\arraystretch{1.2}%
+  \array{@{}l@{\quad}l@{}}%
+}
+\ifx \env at cases\@tempa % add a bit of space after brace in amsmath cases env
+\def\env at cases{%
+  \let\@ifnextchar\new at ifnextchar
+  \left\lbrace\hskip 2\p@
+  \def\arraystretch{1.2}%
+  \array{@{}l@{\quad}l@{}}%
+}
+\fi
+}% end amsmath branch
+
 \def\numc at left{\@centering}
 \def\numc at opts{\dimen at ii\displaywidth}
+\def\numc at forcenumwid{\numc at numwid}
 
-\DeclareOption{subnum}{
-  \let\numc at setsub\subequations 
-  \let\numc at resetsub\endsubequations }
+\DeclareOption{subnum}{%
+  \let\numc at setsub\numc at subequations 
+  \let\numc at resetsub\endsubequations
+}
 
 \DeclareOption{fleqn}{
-  \def\numc at left{\mathindent}
-  \def\numc at opts{\displaywidth\linewidth 
-  \dimen at ii\linewidth }
+  \let\numc at left\mathindent
+  \def\numc at opts{\displaywidth\linewidth
+    \dimen at ii\linewidth }
 }
-\ProcessOptions 
 
+\DeclareOption{leqno}{
+  \let\numc at forcenumwid\z@
+}
+
+\let\numc at expstyle\@empty
+\let\numc at dispstyle\displaystyle
+\DeclareOption{amsstyle}{
+  \def\numc at expstyle{$}% used in pairs for math-mode ($) explanation
+  \let\numc at dispstyle\textstyle
+}
+
+\DeclareOption{casesstyle}{
+ \newcommand\@unnc at casecr[1][\z at skip]{%
+  \cr \noalign{\vskip #1}%
+ }
+ \renewenvironment{cases}{%
+  \let\@ifnextchar\new at ifnextchar
+  \left\lbrace\hskip 2\p@
+  \vcenter to1.3em{}%
+  \vcenter\bgroup
+    \let\\\@unnc at casecr
+    \openup\jot
+    \tabskip\z at skip 
+    \halign \bgroup 
+      $\numc at dispstyle{##}\m at th$\hfil 
+      &\numc at expstyle\quad ##\unskip\numc at expstyle\hfil % \unskip removes space if no explanations
+      \cr
+ }{%
+      \crcr
+    \egroup
+  \egroup
+  \right.\n at space  
+ }
+}
+
+\DeclareOption{cases}{\ExecuteOptions{casesstyle}}
+
+\ProcessOptions
+
 \endinput
 
 % Send problem reports to asnd at triumf.ca



More information about the tex-live-commits mailing list.