\documentclass{report}

% Setting hypertexnames=false forces hyperref to use a consistent
% internal counter for proposition/equation references rather than
% being clever, which doesn't work after we reset those counters.
\usepackage[hypertexnames=false]{hyperref}
\hypersetup{
  colorlinks=true,
  linkcolor=blue,
  citecolor=blue
}

% We have to load this after hyperref, so that links work, but before
% mjotex so that mjotex knows to define its glossary entries.
\usepackage[nonumberlist]{glossaries}
\makenoidxglossaries{}

% If you want an index, we can do that too. You'll need to define
% the "INDICES" variable in the GNUmakefile, though.
\usepackage{makeidx}
\makeindex

\usepackage{mjotex}
\usepackage{mathtools}

\begin{document}

  \begin{section}{Algebra}
    If $R$ is a commutative ring\index{commutative ring}, then
    $\polyring{R}{X,Y,Z}$ is a multivariate polynomial ring with
    indeterminates $X$, $Y$, and $Z$, and coefficients in $R$. If $R$
    is a moreover an integral domain, then its fraction field is
    $\Frac{R}$. If $x,y,z \in R$, then $\ideal{\set{x,y,z}}$ is the
    ideal generated by $\set{x,y,z}$, which is defined to be the
    smallest ideal in $R$ containing that set. Likewise, if we are in
    an algebra $\mathcal{A}$ and if $x,y,z \in \mathcal{A}$, then
    $\alg{\set{x,y,z}}$ is the smallest subalgebra of $\mathcal{A}$
    containing the set $\set{x,y,z}$.

    If $R$ has a multiplicative identity (that is, a unit) element,
    then that element is denoted by $\unit{R}$. Its additive identity
    element is $\zero{R}$. The stabilizer (or isotropy)
    subgroup of $G$ that fixes $x$ is $\Stab{G}{x}$.
  \end{section}

  \begin{section}{Algorithm}
    An example of an algorithm (bogosort) environment.

    \begin{algorithm}[H]
      \caption{Sort a list of numbers}
      \begin{algorithmic}
        \Require{A list of numbers $L$}
        \Ensure{A new, sorted copy $M$ of the list $L$}

        \State{$M \gets L$}

        \While{$M$ is not sorted}
          \State{Rearrange $M$ randomly}
        \EndWhile{}

        \State{\Return{$M$}}
      \end{algorithmic}
    \end{algorithm}
  \end{section}

  \begin{section}{Arrow}
    The constant function that always returns $a$ is $\const{a}$. The
    identity operator on $V$ is $\identity{V}$. The composition of $f$
    and $g$ is $\compose{f}{g}$. The inverse of $f$ is
    $\inverse{f}$. If $f$ is a function and $A$ is a subset of its
    domain, then the preimage under $f$ of $A$ is $\preimage{f}{A}$.
  \end{section}

  \begin{section}{Calculus}
    The gradient of $f : \Rn \rightarrow \Rn[1]$ is $\gradient{f} :
    \Rn \rightarrow \Rn$.
  \end{section}

  \begin{section}{Common}
    The function $f$ applied to $x$ is $f\of{x}$, and the restriction
    of $f$ to a subset $X$ of its domain is $\restrict{f}{X}$. We can
    group terms like $a + \qty{b - c}$ or $a + \qty{b - \sqty{c -
        d}}$. The tuples go up to seven, for now, and then we give up
    and use the general construct:
    %
    \begin{itemize}
      \begin{item}
        Pair: $\pair{1}{2}$,
      \end{item}
      \begin{item}
        Triple: $\triple{1}{2}{3}$,
      \end{item}
      \begin{item}
        Quadruple: $\quadruple{1}{2}{3}{4}$,
      \end{item}
      \begin{item}
        Qintuple: $\quintuple{1}{2}{3}{4}{5}$,
      \end{item}
      \begin{item}
        Sextuple: $\sextuple{1}{2}{3}{4}{5}{6}$,
      \end{item}
      \begin{item}
        Septuple: $\septuple{1}{2}{3}{4}{5}{6}{7}$.
      \end{item}
      \begin{item}
        Tuple: $\tuple{1,2,\ldots,8675309}$.
      \end{item}
    \end{itemize}
    %
    The factorial of the number $10$ is $\factorial{10}$, and the
    least common multiple of $4$ and $6$ is $\lcm{\set{4,6}} =
    12$.

    The direct sum of $V$ and $W$ is $\directsum{V}{W}$. Or three
    things, $\directsumthree{U}{V}{W}$. How about more things? Like
    $\directsummany{k=1}{\infty}{V_{k}}$. Those direct sums
    adapt nicely to display equations:
    %
    \begin{equation*}
      \directsummany{k=1}{\infty}{V_{k}} \ne \emptyset.
    \end{equation*}
    %
    Here are a few common tuple spaces that should not have a
    superscript when that superscript would be one: $\Nn[1]$,
    $\Zn[1]$, $\Qn[1]$, $\Rn[1]$, $\Cn[1]$. However, if the
    superscript is (say) two, then it appears: $\Nn[2]$, $\Zn[2]$,
    $\Qn[2]$, $\Rn[2]$, $\Cn[2]$. The symbols $\Fn[1]$, $\Fn[2]$,
    et cetera, are available for use with a generic field.

    Finally, we have the four standard types of intervals in $\Rn[1]$,
    %
    \begin{align*}
      \intervaloo{a}{b} &= \setc{ x \in \Rn[1]}{ a < x < b },\\
      \intervaloc{a}{b} &= \setc{ x \in \Rn[1]}{ a < x \le b },\\
      \intervalco{a}{b} &= \setc{ x \in \Rn[1]}{ a \le x < b }, \text{ and }\\
      \intervalcc{a}{b} &= \setc{ x \in \Rn[1]}{ a \le x \le b }.
    \end{align*}
  \end{section}

  \begin{section}{Complex}
    We sometimes want to conjugate complex numbers like
    $\compconj{a+bi} = a - bi$.
  \end{section}

  \begin{section}{Cone}
    The dual cone of $K$ is $\dual{K}$. Some familiar symmetric cones
    are $\Rnplus$, $\Rnplusplus$, $\Lnplus$, $\Snplus$, and $\Hnplus$.
    If cones $K_{1}$ and $K_{2}$ are given, we can define
    $\posops{K_{1}}$, $\posops[K_{2}]{K_{1}}$, $\Sof{K_{1}}$,
    $\Zof{K_{1}}$, $\LL{K_{1}}$, and $\lyapunovrank{K_{1}}$. We can
    also define $x \gecone_{K} y$, $x \gtcone_{K} y$, $x \lecone_{K}
    y$, and $x \ltcone_{K} y$ with respect to a cone $K$.
  \end{section}

  \begin{section}{Convex}
    The conic hull of a set $X$ is $\cone{X}$; its affine hull is
    $\aff{X}$, and its convex hull is $\conv{X}$. If $K$ is a cone,
    then its lineality space is $\linspace{K}$, its lineality is
    $\lin{K}$, and its extreme directions are $\Ext{K}$. The fact that
    $F$ is a face of $K$ is denoted by $F \faceof K$; if $F$ is a
    proper face, then we write $F \properfaceof K$.
  \end{section}

  \begin{section}{Euclidean Jordan algebras}
    The Jordan product of $x$ and $y$ in some Euclidean Jordan algebra
    $V$ is $\jp{x}{y}$. The Jordan-automorphism group of $V$ is
    $\JAut{V}$. Two popular operators in an EJA are its quadratic
    representation and ``left multiplication by'' operator. For a
    given $x$, they are, respectively, $\quadrepr{x}$ and
    $\leftmult{x}$.
  \end{section}

  \begin{section}{Font}
    We can write things like Carathéodory and Güler and
    $\mathbb{R}$. The PostScript Zapf Chancery font is also available
    in both upper- and lower-case:
    %
    \begin{itemize}
      \begin{item}$\mathpzc{abcdefghijklmnopqrstuvwxyz}$\end{item}
      \begin{item}$\mathpzc{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$\end{item}
    \end{itemize}
  \end{section}

  \begin{section}{Hurwitz}
    Here lies the Hurwitz algebras, like the quaternions
    $\quaternions$ and octonions $\octonions$.
  \end{section}

  \begin{section}{Linear algebra}
    The absolute value of $x$ is $\abs{x}$, or its norm is
    $\norm{x}$. The inner product of $x$ and $y$ is $\ip{x}{y}$ and
    their tensor product is $\tp{x}{y}$. The Kronecker product of
    matrices $A$ and $B$ is $\kp{A}{B}$. The adjoint of the operator
    $L$ is $\adjoint{L}$, or if it's a matrix, then its transpose is
    $\transpose{L}$. Its trace is $\trace{L}$, and its spectrum---the
    set of its eigenvalues---is $\spectrum{L}$. Another
    matrix-specific concept is the Moore-Penrose pseudoinverse of $L$,
    denoted by $\pseudoinverse{L}$. Finally, the rank of a matrix $L$
    is $\rank{L}$. As far as matrix spaces go, we have the $n$-by-$n$
    real-symmetric and complex-Hermitian matrices $\Sn$ and $\Hn$
    respectively; however $\Sn[1]$ and $\Hn[1]$ do not automatically
    simplify because the ``$n$'' does not indicate the arity of a
    Cartesian product in this case. A handy way to represent the
    matrix $A \in \Rn[n \times n]$ whose only non-zero entries are on
    the diagonal is $\diag{\colvec{A_{11},A_{22},\ldots,A_{nn}}}$.

    The span of a set $X$ is $\spanof{X}$, and its codimension is
    $\codim{X}$. The projection of $X$ onto $V$ is $\proj{V}{X}$. The
    automorphism group of $X$ is $\Aut{X}$, and its Lie algebra is
    $\Lie{X}$. We can write a column vector $x \coloneqq
    \colvec{x_{1},x_{2},x_{3},x_{4}}$ and turn it into a $2 \times 2$
    matrix with $\matricize{x}$. To recover the vector, we use
    $\vectorize{\matricize{x}}$.

    The set of all bounded linear operators from $V$ to $W$ is
    $\boundedops[W]{V}$. If $W = V$, then we write $\boundedops{V}$
    instead. If you have matrices instead, then the general linear
    group of $n$-by-$n$ matrices with entries in $\mathbb{F}$ is
    $\GL{n}{\mathbb{F}}$.

    If you want to solve a system of equations, try Cramer's
    rule~\cite{ehrenborg}. Or at least the reduced row-echelon form of
    the matrix, $\rref{A}$.

    The direct sum of $V$ and $W$ is $\directsum{V}{W}$, of course,
    but what if $W = V^{\perp}$? Then we wish to indicate that fact by
    writing $\directsumperp{V}{W}$. That operator should survive a
    display equation, too, and the weight of the circle should match
    that of the usual direct sum operator.
    %
    \begin{align*}
      Z = \directsumperp{V}{W}\\
      \oplus \oplusperp \oplus \oplusperp
    \end{align*}
    %
    Its form should also survive in different font sizes\ldots
    \Large
    \begin{align*}
      Z = \directsumperp{V}{W}\\
      \oplus \oplusperp \oplus \oplusperp
    \end{align*}
    \Huge
    \begin{align*}
      Z = \directsumperp{V}{W}\\
      \oplus \oplusperp \oplus \oplusperp
    \end{align*}
    \normalsize
  \end{section}

  \begin{section}{Listing}
    Here's an interactive SageMath prompt:

    \begin{tcblisting}{listing only,
                       colback=codebg,
                       coltext=codefg,
                       listing options={language=sage,style=sage}}
    sage: K = Cone([ (1,0), (0,1) ])
    sage: K.positive_operator_gens()
    [
    [1 0]  [0 1]  [0 0]  [0 0]
    [0 0], [0 0], [1 0], [0 1]
    ]
    \end{tcblisting}

    However, the smart way to display a SageMath listing is to load it
    from an external file (under the ``listings'' subdirectory):

    \sagelisting{example}

    Keeping the listings in separate files makes it easy for the build
    system to test them.
  \end{section}

  \begin{section}{Proof by cases}

    \begin{proposition}
      There are two cases in the following proof.

      \begin{proof}
        The result should be self-evident once we have considered the
        following two cases.
        \begin{pcases}
          \begin{case}[first case]
            Nothing happens in the first case.
          \end{case}
          \begin{case}[second case]
            The same thing happens in the second case.
          \end{case}
        \end{pcases}

        You see?
      \end{proof}
    \end{proposition}

    Here's another one.

    \renewcommand{\baselinestretch}{2}
    \begin{proposition}
      Cases should display intelligently even when the document is
      double-spaced.

      \begin{proof}
        Here we go again.

        \begin{pcases}
          \begin{case}[first case]
            Nothing happens in the first case.
          \end{case}
          \begin{case}[second case]
            The same thing happens in the second case.
          \end{case}
        \end{pcases}

        Now it's over.
      \end{proof}
    \end{proposition}
    \renewcommand{\baselinestretch}{1}
  \end{section}

  \begin{section}{Set theory}
    Here's a set $\set{1,2,3} = \setc{n \in \Nn[1]}{ n \le 3 }$. The
    cardinality of the set $X \coloneqq \set{1,2,3}$ is $\card{X} =
    3$, and its powerset is $\powerset{X}$.

    We also have a few basic set operations, for example the union of
    two or three sets: $\union{A}{B}$, $\unionthree{A}{B}{C}$. And of
    course with union comes intersection: $\intersect{A}{B}$,
    $\intersectthree{A}{B}{C}$. The Cartesian product of two sets $A$
    and $B$ is there too: $\cartprod{A}{B}$. If we take the product
    with $C$ as well, then we obtain $\cartprodthree{A}{B}{C}$.

    We can also take an arbitrary (indexed) union, intersection, or
    Cartesian product of things, like
    $\unionmany{k=1}{\infty}{A_{k}}$,
    $\intersectmany{k=1}{\infty}{B_{k}}$, or
    $\cartprodmany{k=1}{\infty}{C_{k}}$. The best part about those is
    that they do the right thing in a display equation:
    %
    \begin{equation*}
      \unionmany{k=1}{\infty}{A_{k}}
      \ne
      \intersectmany{k=1}{\infty}{B_{k}}
      \ne
      \cartprodmany{k=1}{\infty}{C_{k}}.
    \end{equation*}
    %
  \end{section}

  \begin{section}{Theorems}
    \begin{corollary}
      The
    \end{corollary}

    \begin{lemma}
      quick
    \end{lemma}

    \begin{proposition}
      brown
    \end{proposition}

    \begin{theorem}
      fox
    \end{theorem}

    \begin{exercise}
      jumps
    \end{exercise}

    \begin{definition}
      quod
    \end{definition}

    \begin{example}
      erat
    \end{example}

    \begin{remark}
      demonstradum.
    \end{remark}
  \end{section}

  \begin{section}{Theorems (starred)}
    \begin{corollary*}
      The
    \end{corollary*}

    \begin{lemma*}
      quick
    \end{lemma*}

    \begin{proposition*}
      brown
    \end{proposition*}

    \begin{theorem*}
      fox
    \end{theorem*}

    \begin{exercise*}
      jumps
    \end{exercise*}

    \begin{definition*}
      quod
    \end{definition*}

    \begin{example*}
      erat
    \end{example*}

    \begin{remark*}
      demonstradum.
    \end{remark*}
  \end{section}

  \begin{section}{Topology}
    The interior of a set $X$ is $\interior{X}$. Its closure is
    $\closure{X}$ and its boundary is $\boundary{X}$.
  \end{section}

  \setlength{\glslistdottedwidth}{.3\linewidth}
  \setglossarystyle{listdotted}
  \glsaddall{}
  \printnoidxglossaries{}

  \bibliographystyle{mjo}
  \bibliography{local-references}

  \printindex
\end{document}
