%% rbt-mathnotes.tex
%% Copyright 2021 Rebecca B. Turner.
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this work is Rebecca B. Turner.
%
% This work consists of the files:
%     README.md
%     rbt-mathnotes.tex
%     rbt-mathnotes.sty
%     rbt-mathnotes.cls
%     rbt-mathnotes-util.sty
%     rbt-mathnotes-messages.sty
%     rbt-mathnotes-hw.cls
%     rbt-mathnotes-formula-sheet.cls
%     examples/cheat-sheet.tex
%     examples/multivar.tex
%     examples/topology-hw-1.tex
% and the derived files:
%     rbt-mathnotes.pdf
%     examples/cheat-sheet.pdf
%     examples/multivar.pdf
%     examples/topology-hw-1.pdf

\documentclass{ltxguidex}

\errorcontextlines=10
\usepackage{longtable}
\usepackage{changepage}
\usepackage{metalogo}
\usepackage{changelog}
\newcommand{\mn}{\ctan{rbt-mathnotes}}

\makeatletter
\renewcommand{\SX@explpreset}{
  language=[LaTeX]TeX,
  numbers=none,
}
\makeatother

%\setmainfont{Charter}
\lstset{basewidth=0.6em}

\usepackage[
  nomaketitle,
  notitles,
  noxcolor,
  noenumitem,
  notheorems,
]{rbt-mathnotes}

\usepackage{FiraSans}
\usepackage{FiraMono}

\NewDocumentEnvironment{ctandescription}{}
  {\NewDocumentCommand{\pkg}{m}{\item[\ctan{##1}]}
  \begin{description}}
  {\end{description}}

\author{Rebecca Turner\thanks{\email{rbt@sent.as}, \https{becca.ooo}}}
\title{The \mn\ Package}
\date{1.0.2 2021/11/29}
\begin{document}
\maketitle

\begin{abstract}
  Rebecca Turner's personal macros and styles for typesetting mathematics
  notes.
\end{abstract}

\begin{note}
  Browse the sources, contribute, or complain at \\
  \https{github.com/9999years/latex-mathnotes}
\end{note}

\tableofcontents
\vfill
\pagebreak

\begin{note}
  Copyright 2021 Rebecca B. Turner.

  This work may be distributed and/or modified under the
  conditions of the LaTeX Project Public License, either version 1.3
  of this license or (at your option) any later version.
  The latest version of this license is in
    \https{www.latex-project.org/lppl.txt}
  and version 1.3 or later is part of all distributions of LaTeX
  version 2005/12/01 or later.

  This work has the LPPL maintenance status `maintained'.

  The Current Maintainer of this work is Rebecca B. Turner.

  This work consists of the files:
    \begin{itemize}
      \item \texttt{README.md}
      \item \texttt{rbt-mathnotes.tex}
      \item \texttt{rbt-mathnotes.sty}
      \item \texttt{rbt-mathnotes.cls}
      \item \texttt{rbt-mathnotes-util.sty}
      \item \texttt{rbt-mathnotes-messages.sty}
      \item \texttt{rbt-mathnotes-hw.cls}
      \item \texttt{rbt-mathnotes-formula-sheet.cls}
      \item \texttt{examples/cheat-sheet.tex}
      \item \texttt{examples/multivar.tex}
      \item \texttt{examples/topology-hw-1.tex}
    \end{itemize}
  and the derived files:
    \begin{itemize}
      \item \texttt{rbt-mathnotes.pdf}
      \item \texttt{examples/cheat-sheet.pdf}
      \item \texttt{examples/multivar.pdf}
      \item \texttt{examples/topology-hw-1.pdf}
    \end{itemize}
\end{note}

\vfill
\pagebreak

\section{Package options}

Some options are enabled by default, and can be disabled by passing
|no<option>|. The enabled-by-default options are:
\begin{keys}
  \key{fonts}[\bool][true]
  \key{stix}[\bool][true]
    \begin{itemize}
      \item In \XeTeX\ or \LuaTeX, loads the \ctan{unicode-math} package, and
        then, if the \option{stix} option is also given, loads the
        \texttt{STIX2Text} and \texttt{STIX2Math} \textsc{otf} fonts (available
        in the \ctan{stix2-otf} package).

        The \texttt{STIX2Math} font is loaded with stylistic sets 1 (roundhand
        script forms instead of chancery script for |\mathcal| Script
        Alphanumeric Symbols) and 8 (upright, rather than slanted, forms for
        integrals); see ``Stylistic Sets'' in
        \href{http://mirrors.ctan.org/fonts/stix2-otf/STIXTwoMath-Regular.pdf}{the
        \texttt{stix2-otf} documentation} (pp.~51--53) for more information.

      \item In other engines, if the \option{stix} option is also given, loads
        the \package{stix2} package from \ctan{stix2-type1}.
    \end{itemize}

  \key{symbols}[\bool][true]

    Defines a collection of ``natural language'' math-mode symbol commands.
    Most commands are declared with |\ProvideDocumentCommand| so that they
    won't overwrite custom commands you've already defined.

    Note that symbols may look different depending on the \option{fonts} and
    \option{stix} options.

    \begin{longtable}{rl}
      |\lnot| & $\lnot$ \\
      |\Rational|, |\Rat|, |\Q| & $\Rational$ \\
      |\Natural|, |\Nat|, |\N| & $\Natural$ \\
      |\Integer|, |\Int|, |\Z| & $\Integer$ \\
      |\Complex|, |\Comp|, |\C| & $\Complex$ \\
      |\Real|, |\R| & $\R$ \\
      |\powerset| & $\powerset$ \\
      |\vec{A}| & $\vec{A}$ \\
      |\intersection|, |\inter| & $\intersection$ \\
      |\bigintersection|, |\biginter| & $\bigintersection$ \\
      |\union| & $\union$ \\
      |\bigunion| & $\bigunion$ \\
      |\divisible|, |\div| & $a \divisible b$ \\
      |\notdivisible|, |\ndivisible|, |\notdiv|, |\ndiv| & $a \notdivisible b$ \\
      |\floor{A}| & $\floor{A}$ \\
      |\ceil{A}| & $\ceil{A}$ \\
      |\emptyset|, |\es| & $\emptyset$ \\
      |\after| & $g \after f$ \\
      |\cross| & $a \cross b$ \\
      |\img| & $\img f$ \\
      |\pre| & $\pre f$ \\
      |\Stab| & $\Stab f$ \\
      |\FixPt| & $\FixPt f$ \\
      |\id| & $\id$ \\
      |\injection|, |\inj| & $\injection$ \\
      |\surjection|, |\surj| & $\surjection$ \\
      |\bijection|, |\bij| & $\bijection$ \\
      |\restriction|, |\restr| & $f \restr_{\N}$ \\
      |\dd[y]{x}| & $\dd[y]{x}$ \\
      |\pd[y]{x}| & $\pd[y]{x}$ \\
      |\curl| & $\curl$ \\
      |\dive| & $\dive$ \\
    \end{longtable}

  \key{maketitle}[\bool][true]
    Redefines |\maketitle| and related commands. The provided |\maketitle|
    command will automatically insert a |\thanks| if any email, course,
    instructor, institution, or semester is supplied with the |\mathnotes|
    command.

  \key{titles}[\bool][true]
    No-op; may set the format of sectioning commands in the future.

  \key{xcolor}[\bool][true]
    Load the \ctan{xcolor} package and defines several colors with the |MN|
    prefix.

  \key{theorems}[\bool][true]
    Set up various theorem environments with the \ctan{ntheorem} and
    \ctan{mdframed} packages.

    Provides |thm| (Theorem), |lem| (Lemma), |cor| (Corollary), |prop|
    (Proposition), |defn| (Definition), |notation|, |ex|
    (Example), |note|, |remark|, |hint|, and |abuse-of-notation| (Abuse of
    notation) theorem-like environments.

  \key{enumitem}[\bool][true]
    Loads the \ctan{enumitem} package.

\end{keys}

The other options are not enabled by default, and can be enabled by passing
|<option>| --- the option name --- as a package option:
\begin{keys}
  \key{listings}[\bool]
    Loads the \ctan{listings} and \ctan{xcolor} packages.
    Sets default styles for listings, including setting the default language to
    |Mathematica|.

  \key{knowledge}\bool]
    Loads the \ctan{knowledge} package and sets up default styles.
    Patches lists so that manually placing |\AP| and |\itemAP| commands is
    unecessary.

  \key{index}[\bool]
    Sets the |knowledge| key and starts indexing with |\makeindex|.

  \key{footnotes}[\bool]
    Loads the \ctan{footmisc} package and sets up footnotes.

  \key{figures}[\bool]
    Loads the \ctan{graphicx} and \ctan{caption} packages and sets up figure
    captions.

  \key{tabu}[\bool]
    Loads the \ctan{multirow}, \ctan{booktabs}, \ctan{longtable}, and
    \ctan{tabu} packages.

    Defines the |\Th| command.

  \key{kindle}[\bool]
    Sets a small page size and tweaks the layout for Kindle devices; designed in
    particular for whatever generation of Kindle Paperwhite I have.
    Only compatible with the \ctan{memoir} document class.

\end{keys}

\section{Commands}

\begin{desc}
|\numberthis|
\end{desc}

At the end of a line (before the |\\|) in an \ctan{amsmath} starred
environment, gives an equation a number.

\begin{LTXexample}
\begin{alignat*}{2}
  x &= y \\
  y &= 2z \numberthis \\
  z &= 1/w
\end{alignat*}
\end{LTXexample}

\begin{desc}
|\labelthis{<label>}|
\end{desc}

At the end of a line (before the |\\|) in an \ctan{amsmath} starred
environment, gives an equation a number and label for referencing.

\begin{LTXexample}
\begin{alignat*}{2}
  x &= y \\
  y &= 2z \labelthis{eq:cool} \\
  z &= 1/w.
\end{alignat*}
As we saw in
Equation~\ref{eq:cool}, \dots
\end{LTXexample}

\begin{desc}
|\newacronym[<command>]{<text>}|
\end{desc}

Defines |\<command>| to be |\textsc{<text>}|; |<command>| defaults to |<text>|
if ommitted.

\begin{LTXexample}
\newacronym{nist}
\newacronym[\seetan]{ctan}

\nist\ is not associated
with \seetan.
\end{LTXexample}

\begin{desc}
|\newacronyms{<acronyms>}|
\end{desc}

Defines a collection of acronym commands together using |\newacronym|;
|<acronyms>| is a comma-separated list of acronyms.

\begin{LTXexample}
\newacronyms{apa, mla}

\apa\ and \mla\ are common
citation styles.
\end{LTXexample}

\begin{desc}
|\mathnotes{<key-value pairs>}|
\end{desc}

\begin{keys}
  \key{date}[\m{date}]
  \key{author}[\m{author}]
  \key{title}[\m{title}]
    Sets the date, author, or title; setting these keys are equivalent to using the
    |\date|, |\author|, and |\title| commands, respectively.

  \key{institution}[\m{institution}]
    Sets the institution (e.g., Brandeis University) associated with the
    document.
  \key{course}[\m{course}]
    Sets the course (e.g., \textsc{math}~23a) associated with the
    document.
  \key{semester}[\m{semester}]
    Sets the semester (e.g., Fall 2018) associated with the document.
  \key{instructor}[\m{instructor}]
    Sets the instructor (e.g., Prof.~Ruth~Charney) associated with the document.
  \key{email}[\m{email}]
    Sets the email (e.g., \email{rbt@sent.as}) associated with the author.
\end{keys}

\begin{desc}
|\TODO[<item>]|
\end{desc}

Typesets a to-do marker.

\begin{LTXexample}
\TODO

\TODO[explain in detail]
\end{LTXexample}

\begin{desc}
|\email{<email>}|
\end{desc}
Typesets an email address, with a link if the \ctan{hyperref} package is loaded.

\begin{LTXexample}
\email{rbt@sent.as}
\end{LTXexample}

\begin{desc}
|\Th[<column spec>]{<header>}|
\end{desc}
Typesets a table column header in bold using |\multicolumn|. Especially useful
if the column in question is a math or numeric column.

\m{column spec} defaults to |l| (left-aligned).

\section{The \texttt{rbt-mathnotes} document class}

The \mn\ document class is a \ctan{memoir}-based class that automatically loads
the \mn\ package.

\section{The \texttt{rbt-mathnotes-hw} document class}

The |rbt-mathnotes-hw| document class is based on the |rbt-mathnotes| document
class, providing additional commands and styles for typesetting homework
assignments.  Theorems are given subtler styling that takes up less space on
the page.  The author name and title are added to the top-left heading.

\begin{desc}
|problem| \\
|\begin{problem}[<number or options>]| \\
|\prob[<number or options>]{<text>}|
\end{desc}

The |problem| environment (and its matching shorthand |\prob|) typesets a
homework problem typesets a homework problem. Problems are added to the table of
contents at the chapter-level, which is the top level if I remember correctly.

\m{number or options} is a list of key-value pairs:

\begin{keys}
  \key{number}[\m{number}]
    Sets the problem's number. For brevity, an unrecognized key with no value
    is also used as the problem number; this allows concise expressions like
    |\begin{problem}[4.3a] ...| to specify problem numbers (to match textbook
    problem numbers, for example). Otherwise, problem numbers
    start at 1 and count up.

  \key{title}[\m{title}]
    Sets the problem's ``title''.

  \key{label}[\m{label}]
    Sets the problem's label (e.g., |prob:n-sheeted-covering|), which can be
    referred to later with |\ref|.
\end{keys}

If your professor calls them ``exercises'' or something, you can change the
string used to refer to them with the |\mathnotes| command, which supports an
additional key in |rbt-mathnotes-hw|:
\begin{keys}
  \key{problem string}[\m{problem string}][Problem]
    The string used to represent a problem in titles and contents entries.
\end{keys}

\pagebreak
\section{The \texttt{rbt-mathnotes-formula-sheet} document class}

Sometimes, exams will let you take any formula sheet of a given size as
reference material. The |rbt-mathnotes-formula-sheet| document class (based on the
\ctan{article} class) is optimized for getting as much material as possible in
that area. A tiny |\maketitle| is provided, as well as a tiny |\section|.
Theorem titles are highly abbreviated (``Thm'' instead of ``Theorem''). Lists
are rendered without linebreaks between items. Paragraphs are compressed and the
page margins are set to a tenth of an inch. The entire document is set in
|\scriptsize|.

Some additional keys are added to the |\mathnotes| command to customize the
output:

\begin{keys}
  \key{columns}[\m{column count}][3]
    The number of text columns to set the formula sheet in; use 1 to turn off
    columns.

  \key{balance columns}
    If set, the unstarred |multicols| environment is used instead of |multicols*|,
    which attempts to spread material between each of the columns evenly, to
    make their vertical sizes as even as possible.

    It doesn't look great --- you want to know when you've filled up one column
    --- so it's off by default.

  \key{width}[\m{width}][8.5in]
  \key{height}[\m{height}][11in]
    Set the paper width and height. The 0.1 inch margins are not customizable.
\end{keys}

\begin{changelog}[author=Rebecca Turner]
  \begin{version}[v=1.0.2, date=2021-11-27, short]
    Added license notice to all files.
  \end{version}

  \begin{version}[v=1.0.1, date=2021-11-24, short]
    Renamed package from \texttt{mathnotes} to \texttt{rbt-mathnotes} to avoid
    a file name conflict with
    \href{http://mirrors.ctan.org/fonts/newtx/doc/mathnotes.pdf}{\texttt{CTAN:/fonts/newtx/doc/mathnotes.pdf}}.
  \end{version}

  \begin{version}[v=1.0.0, date=2021-11-04, short]
    Initial release as \texttt{mathnotes}, documented package.
  \end{version}
\end{changelog}

\end{document}
