]> gitweb.michael.orlitzky.com - mjotex.git/blob - mjo-proof_by_cases.tex
mjo-algebra.tex: fix glossary sorting of \variety
[mjotex.git] / mjo-proof_by_cases.tex
1 %
2 % A proof-by-cases environment. This gives you a nicely-indented list
3 % of cases for use in proofs.
4 %
5 % Example:
6 %
7 % Case 1 (x >= 0): herp.
8 %
9 % Case 2 (x < 0): derp.
10 %
11 \ifx\havemjoproofbycases\undefined
12 \def\havemjoproofbycases{1}
13
14
15 % Used below to define pcases. The ``loadonly'' parameter prevents
16 % a very bad interaction with the beamer document class.
17 \usepackage[loadonly]{enumitem}
18
19 % Needed to perform division in the definition of \singleblskip.
20 \usepackage{calc}
21
22 % A \baselineskip without the \baselinestretch scaling factor. Even
23 % though \baselinestretch defaults to 1.0, it doesn't really have that
24 % value. Thus to avoid division by zero, we need to do the ``is this
25 % thing empty?'' hack.
26 %
27 % If we use \baselineskip instead of \singleblskip in our list, things
28 % get real ugly when the text is e.g. double-spaced.
29 %
30 \newlength{\singleblskip}
31 \setlength{\singleblskip}{
32 \baselineskip/\real{
33 \if\relax\detokenize{\baselinestretch}\relax
34 \baselinestretch%
35 \else
36 1%
37 \fi}
38 }
39
40 % Using the enumitem package, we define a new type of list, called
41 % ``pcases'' (proof by cases). Each case has a label with an arabic
42 % numeral (the case number), but also a \thiscase identifier. The
43 % macro \thiscase is defined below by the \case command, and gives the
44 % name or conditions or whatever that distinguish one case from
45 % another.
46 \newlist{pcases}{enumerate}{1}
47 \setlist[pcases]{
48 label=\textit{Case~\arabic*}:~\protect\thiscase\textit{.},
49 ref=\arabic*,
50 align=left,
51 listparindent=\parindent,
52 parsep=\parskip,
53 itemsep=\singleblskip}
54
55 % The optional argument here gets stuffed into the \thiscase macro, to
56 % be called by pcases when it creates this list item. The \hfill is a
57 % hack intended to force the proof to start on a new line, rather than
58 % right after the colon. A \newline where the \hfill is does not work,
59 % so we consume the rest of the line instead.
60 \newcommand{\case}[1][]{
61 \def\thiscase{#1}%
62 \item \hfill\par\vspace{\singleblskip}
63 }
64
65
66 \fi