summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/cases
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/cases
Initial commit
Diffstat (limited to 'macros/latex/contrib/cases')
-rw-r--r--macros/latex/contrib/cases/cases.pdfbin0 -> 319574 bytes
-rw-r--r--macros/latex/contrib/cases/cases.sty187
-rw-r--r--macros/latex/contrib/cases/cases.tex148
3 files changed, 335 insertions, 0 deletions
diff --git a/macros/latex/contrib/cases/cases.pdf b/macros/latex/contrib/cases/cases.pdf
new file mode 100644
index 0000000000..2274952e82
--- /dev/null
+++ b/macros/latex/contrib/cases/cases.pdf
Binary files differ
diff --git a/macros/latex/contrib/cases/cases.sty b/macros/latex/contrib/cases/cases.sty
new file mode 100644
index 0000000000..b82f010a02
--- /dev/null
+++ b/macros/latex/contrib/cases/cases.sty
@@ -0,0 +1,187 @@
+% C A S E S . S T Y ver 2.5 May 2002
+%
+% Copyright (C) 1993,1994,1995,2000,2002 by Donald Arseneau
+% asnd@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.
+%
+% This provides a LaTeX environment {numcases} to produce multi-case
+% equations with a separate equation number for each case. There is
+% also {subnumcases} which numbers each case with the overall equation
+% number plus a letter [8a, 8b, etc.]. The syntax is
+%
+% \begin{numcases}{left_side}
+% case_1 & explanation_1 \\
+% case_2 & explanation_2 \\
+% ...
+% case_n & explanation_n
+% \end{numcases}
+%
+% Each case is a math formula, and each explanation is a piece of lr mode
+% text (which may contain math mode in \(...\) or $...$). The explanations
+% are optional. Equation numbers are inserted automatically, just as for
+% the eqnarray environment. In particular, the \nonumber command suppresses
+% an equation number and the \label command allows reference to a particular
+% 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 - - -
+
+\ProvidesPackage{cases}[2002/05/02 ver 2.5 ]
+
+\newenvironment{numcases}[1]%
+{$$\numc@opts \setbox\z@\hbox
+ {\advance\c@equation\@ne\def\@currentlabel{\p@equation\theequation}% local
+ $\displaystyle {#1\null}\m@th$}%
+ \numc@setsub
+ \setbox\tw@\vbox\bgroup
+ \stepcounter{equation}\def\@currentlabel{\p@equation\theequation}%
+ \global\@eqnswtrue\m@th \everycr{}\tabskip\numc@left\let\\\@eqncr
+ \halign to\dimen@ii \bgroup \kern\wd\z@ \kern14\p@ % assume width of brace
+ \tabskip\z@skip \global\@eqcnt\@ne $\displaystyle{##}$\hfil
+ &\global\@eqcnt\tw@ \skip@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@skip\cr
+}{\@@eqncr \egroup % end \halign, which does not contain first column or brace
+ \global\advance\c@equation\m@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@i\wd\z@
+ \setbox\z@\hbox{\hskip-\numc@left\unhbox\z@}% Measure its natural width
+ \ifdim \wd\z@<\dimen@i \global\dimen@i\wd\z@ \fi
+\egroup% end \vbox (box\tw@, box\z@ is restored to LHS)
+\hbox to\dimen@ii{\m@th % assemble the whole equation
+ \hskip\numc@left
+ \hbox to\dimen@i{$\displaystyle \box\z@ % parameter #1
+ \dimen@\ht\tw@ \advance\dimen@\dp\tw@ % get size of brace
+ \left\{\vcenter to\dimen@{\vfil}\right.\n@space % make brace
+ $\hfil}\hskip\@centering % finished first part (filled whole line)
+ \kern-\dimen@ii % backspace the full width
+ $\vcenter{\box\tw@}$% overlay the alignment
+ }% end the \hbox to\dimen@ii
+\numc@resetsub
+$$\global\@ignoretrue}
+
+\let\numc@setsub\relax
+\let\numc@resetsub\relax
+
+\def\subnumcases{\let\numc@setsub\subequations
+ \let\numc@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.
+
+\@ifundefined{c@parentequation}{% No AMS, define subequations from scratch:
+%
+% These versions of subequations follow the style of Gildea's subeqn.sty,
+% but are thoroughly rewritten.
+%
+% You can change the labelling by redefining \thesubequation, but the names
+% of the counters may be confusing: The sub-number is given by counter
+% {equation}, while the overall equation number is given by {mainequation}.
+% There are two ways to reference the overall equation number:
+% through the value of \c@mainequation, as in \Roman{mainequation}, or
+% through \themainequation, which gives the text of the normal \theequation.
+% Refer to the local sub-number with \c@equation, as in \alph{equation}.
+% The default numbering is like 13c, given by:
+%
+\def\thesubequation{\themainequation\alph{equation}}
+%
+% Some alternatives:
+% \def\thesubequation{\themainequation.\Alph{equation}} % 13.C
+% \def\thesubequation{\themainequation-\roman{equation}} % 13-iii
+% \def\thesubequation{(\arabic{mainequation}\alph{equation})} % (13c)
+% The third alternative should be used if a document style has
+% declared \renewcommand{\@eqnnum}{\theequation} and
+% \renewcommand{\theequation}{(\arabic{equation})}, which makes
+% \ref put parentheses around regular equation numbers automatically.
+%
+\def\subequations{\refstepcounter{equation}%
+ \mathchardef\c@mainequation\c@equation
+ \let\@tempa\protect % * added protection
+ \def\protect{\noexpand\protect\noexpand}% *
+ \edef\themainequation{\theequation}\let\theequation\thesubequation
+ \let\protect\@tempa % *
+ \global\c@equation\z@}
+%
+\def\endsubequations{%
+ \global\c@equation\c@mainequation
+ \global\@ignoretrue}
+%
+% \begin{subeqnarray} works like \begin{subequations}\begin{eqnarray},
+% with the added feature that a \label command given given at the very
+% beginning of the first entry defines a label for the overall equation
+% number.
+%
+\def\subeqnarray{\subequations\eqnarray\@ifnextchar\label{\@lab@subeqnarray}{}}
+\def\endsubeqnarray{\endeqnarray\endsubequations}
+\def\@lab@subeqnarray#1#2{\begingroup
+ \let\@currentlabel\themainequation #1{#2}\endgroup}
+%
+}{}% AMS \subequations already defined
+
+\def\numc@left{\@centering}
+\def\numc@opts{\dimen@ii\displaywidth}
+
+\DeclareOption{subnum}{
+ \let\numc@setsub\subequations
+ \let\numc@resetsub\endsubequations }
+
+\DeclareOption{fleqn}{
+ \def\numc@left{\mathindent}
+ \def\numc@opts{\displaywidth\linewidth
+ \dimen@ii\linewidth }
+}
+\ProcessOptions
+
+\endinput
+
+% Send problem reports to asnd@triumf.ca
+
+Test file integrity: ASCII 32-57, 58-126: !"#$%&'()*+,-./0123456789
+:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
diff --git a/macros/latex/contrib/cases/cases.tex b/macros/latex/contrib/cases/cases.tex
new file mode 100644
index 0000000000..93311c2b1d
--- /dev/null
+++ b/macros/latex/contrib/cases/cases.tex
@@ -0,0 +1,148 @@
+\documentclass[DIV=9, pagesize=auto]{scrartcl}
+
+\usepackage{fixltx2e}
+\usepackage{lmodern}
+\usepackage[T1]{fontenc}
+\usepackage{textcomp}
+\usepackage{amsmath}
+\usepackage{cases}
+\usepackage{microtype}
+\usepackage{hyperref}
+
+\newcommand*{\fancybreak}{%
+ \par
+ \nopagebreak\medskip\nopagebreak
+ \noindent\null\hfill$*\quad*\quad*\quad$\hfill\null\par
+ \nopagebreak\medskip\pagebreak[0]%
+}
+\newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}}
+\newcommand*{\pkg}[1]{\textsf{#1}}
+\newcommand*{\cmd}[1]{\texttt{\string#1}}
+\newcommand*{\env}[1]{\texttt{#1}}
+\newcommand*{\meta}[1]{\textlangle\textsl{#1}\textrangle}
+
+\addtokomafont{title}{\rmfamily}
+
+\title{The \pkg{cases} package\thanks{This manual corresponds to \pkg{cases}~v2.5, dated~May 2002.}}
+\author{Donald Arseneau\\\mail{asnd@triumf.ca}}
+\date{May 2002}
+
+
+\begin{document}
+
+\maketitle
+
+\begingroup
+\small
+\noindent
+Copyright \textcopyright~1993, 1994, 1995, 2000, 2002 by Donald Arseneau, \mail{asnd@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.
+\par
+\endgroup
+
+\fancybreak
+
+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
+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}
+%
+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
+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
+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}.
+
+\emph{Question:} Is there a \verb+{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.
+
+\fancybreak
+
+\noindent
+A simple example is:
+%
+\begin{verbatim}
+\begin{numcases}{|x|=}
+ x, & for $x \geq 0$\\
+ -x, & for $x < 0$
+\end{numcases}
+\end{verbatim}
+%
+Giving:
+%
+\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|$
+\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}
+
+\pagebreak[2]
+
+\noindent
+This was produced by:
+%
+\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|$
+\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}
+\end{verbatim}
+
+\end{document}