% ea-notes.sty -- a personal style for typeset lecture notes.
%
% Evan Angelone, 2026.  Sans-serif headings, framed theorem-like
% environments, and a two-line running header.  Colours are the Mantine
% palette so the notes match the accompanying web material.

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{ea-notes}[2026/05/01 Evan Angelone notes style]


% --------------------------------------------------------------------------
% Packages
% --------------------------------------------------------------------------

\usepackage{amsmath,amssymb,mathtools}
\usepackage{blindtext}
\usepackage[dvipsnames,svgnames,x11names]{xcolor}

\usepackage[
	colorlinks=true,
	citecolor=Blue3,
	linkcolor=Blue3,
	filecolor=violet,
	urlcolor=violet
]{hyperref}

\usepackage[
	backend=biber,
	style=numeric,
	sorting=nyt
]{biblatex}

\usepackage{needspace}
\usepackage[nameinlink, capitalize, noabbrev]{cleveref}

% Capitalised names on both \cref and \Cref, so references read the same
% wherever they land in a sentence.
\crefname{theorem}{Theorem}{Theorems}
\Crefname{theorem}{Theorem}{Theorems}
\crefname{lemma}{Lemma}{Lemmas}
\Crefname{lemma}{Lemma}{Lemmas}
\crefname{proposition}{Proposition}{Propositions}
\Crefname{proposition}{Proposition}{Propositions}
\crefname{corollary}{Corollary}{Corollaries}
\Crefname{corollary}{Corollary}{Corollaries}
\crefname{conjecture}{Conjecture}{Conjectures}
\Crefname{conjecture}{Conjecture}{Conjectures}
\crefname{example}{Example}{Examples}
\Crefname{example}{Example}{Examples}

\usepackage[
	activate={true,nocompatibility},
	tracking=true,
	kerning=true,
	spacing={true},
	factor=1100,
	stretch=10,
	shrink=10,
	nopatch=footnote,
	final,
]{microtype}
\microtypecontext{spacing=nonfrench}

\usepackage{geometry}
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{mdframed}

\usepackage{enumitem}
\setlist[enumerate]{noitemsep, leftmargin=3em}
\setlist[itemize]{noitemsep}

\newlist{thmenumerate}{enumerate}{2}
\setlist[thmenumerate]{noitemsep, label=\sffamily\bfseries\arabic*.}


% --------------------------------------------------------------------------
% Colours -- Mantine palette v1.9.1
% --------------------------------------------------------------------------

\definecolor{white}{RGB}{255, 255, 255}
\definecolor{black}{RGB}{0, 0, 0}

\definecolor{gray-0}{RGB}{248, 249, 250}
\definecolor{gray-1}{RGB}{241, 243, 245}
\definecolor{gray-2}{RGB}{233, 236, 239}
\definecolor{gray-3}{RGB}{222, 226, 230}
\definecolor{gray-4}{RGB}{206, 212, 218}
\definecolor{gray-5}{RGB}{173, 181, 189}
\definecolor{gray-6}{RGB}{134, 142, 150}
\definecolor{gray-7}{RGB}{73, 80, 87}
\definecolor{gray-8}{RGB}{52, 58, 64}
\definecolor{gray-9}{RGB}{33, 37, 41}

\definecolor{red-0}{RGB}{255, 245, 245}
\definecolor{red-1}{RGB}{255, 227, 227}
\definecolor{red-2}{RGB}{255, 201, 201}
\definecolor{red-3}{RGB}{255, 168, 168}
\definecolor{red-4}{RGB}{255, 135, 135}
\definecolor{red-5}{RGB}{255, 107, 107}
\definecolor{red-6}{RGB}{250, 82, 82}
\definecolor{red-7}{RGB}{240, 62, 62}
\definecolor{red-8}{RGB}{224, 49, 49}
\definecolor{red-9}{RGB}{201, 42, 42}

\definecolor{pink-0}{RGB}{255, 240, 246}
\definecolor{pink-1}{RGB}{255, 222, 235}
\definecolor{pink-2}{RGB}{252, 194, 215}
\definecolor{pink-3}{RGB}{250, 162, 193}
\definecolor{pink-4}{RGB}{247, 131, 172}
\definecolor{pink-5}{RGB}{240, 101, 149}
\definecolor{pink-6}{RGB}{230, 73, 128}
\definecolor{pink-7}{RGB}{214, 51, 108}
\definecolor{pink-8}{RGB}{194, 37, 92}
\definecolor{pink-9}{RGB}{166, 30, 77}

\definecolor{grape-0}{RGB}{248, 240, 252}
\definecolor{grape-1}{RGB}{243, 217, 250}
\definecolor{grape-2}{RGB}{238, 190, 250}
\definecolor{grape-3}{RGB}{229, 153, 247}
\definecolor{grape-4}{RGB}{218, 119, 242}
\definecolor{grape-5}{RGB}{204, 93, 232}
\definecolor{grape-6}{RGB}{190, 75, 219}
\definecolor{grape-7}{RGB}{174, 62, 201}
\definecolor{grape-8}{RGB}{156, 54, 181}
\definecolor{grape-9}{RGB}{134, 46, 156}

\definecolor{violet-0}{RGB}{243, 240, 255}
\definecolor{violet-1}{RGB}{229, 219, 255}
\definecolor{violet-2}{RGB}{208, 191, 255}
\definecolor{violet-3}{RGB}{177, 151, 252}
\definecolor{violet-4}{RGB}{151, 117, 250}
\definecolor{violet-5}{RGB}{132, 94, 247}
\definecolor{violet-6}{RGB}{121, 80, 242}
\definecolor{violet-7}{RGB}{112, 72, 232}
\definecolor{violet-8}{RGB}{103, 65, 217}
\definecolor{violet-9}{RGB}{95, 61, 196}

\definecolor{indigo-0}{RGB}{237, 242, 255}
\definecolor{indigo-1}{RGB}{219, 228, 255}
\definecolor{indigo-2}{RGB}{186, 200, 255}
\definecolor{indigo-3}{RGB}{145, 167, 255}
\definecolor{indigo-4}{RGB}{116, 143, 252}
\definecolor{indigo-5}{RGB}{92, 124, 250}
\definecolor{indigo-6}{RGB}{76, 110, 245}
\definecolor{indigo-7}{RGB}{66, 99, 235}
\definecolor{indigo-8}{RGB}{59, 91, 219}
\definecolor{indigo-9}{RGB}{54, 79, 199}

\definecolor{blue-0}{RGB}{231, 245, 255}
\definecolor{blue-1}{RGB}{208, 235, 255}
\definecolor{blue-2}{RGB}{165, 216, 255}
\definecolor{blue-3}{RGB}{116, 192, 252}
\definecolor{blue-4}{RGB}{77, 171, 247}
\definecolor{blue-5}{RGB}{51, 154, 240}
\definecolor{blue-6}{RGB}{34, 139, 230}
\definecolor{blue-7}{RGB}{28, 126, 214}
\definecolor{blue-8}{RGB}{25, 113, 194}
\definecolor{blue-9}{RGB}{24, 100, 171}

\definecolor{cyan-0}{RGB}{227, 250, 252}
\definecolor{cyan-1}{RGB}{197, 246, 250}
\definecolor{cyan-2}{RGB}{153, 233, 242}
\definecolor{cyan-3}{RGB}{102, 217, 232}
\definecolor{cyan-4}{RGB}{59, 201, 219}
\definecolor{cyan-5}{RGB}{34, 184, 207}
\definecolor{cyan-6}{RGB}{21, 170, 191}
\definecolor{cyan-7}{RGB}{16, 152, 173}
\definecolor{cyan-8}{RGB}{12, 133, 153}
\definecolor{cyan-9}{RGB}{11, 114, 133}

\definecolor{teal-0}{RGB}{230, 252, 245}
\definecolor{teal-1}{RGB}{195, 250, 232}
\definecolor{teal-2}{RGB}{150, 242, 215}
\definecolor{teal-3}{RGB}{99, 230, 190}
\definecolor{teal-4}{RGB}{56, 217, 169}
\definecolor{teal-5}{RGB}{32, 201, 151}
\definecolor{teal-6}{RGB}{18, 184, 134}
\definecolor{teal-7}{RGB}{12, 166, 120}
\definecolor{teal-8}{RGB}{9, 146, 104}
\definecolor{teal-9}{RGB}{8, 127, 91}

\definecolor{green-0}{RGB}{235, 251, 238}
\definecolor{green-1}{RGB}{211, 249, 216}
\definecolor{green-2}{RGB}{178, 242, 187}
\definecolor{green-3}{RGB}{140, 233, 154}
\definecolor{green-4}{RGB}{105, 219, 124}
\definecolor{green-5}{RGB}{81, 207, 102}
\definecolor{green-6}{RGB}{64, 192, 87}
\definecolor{green-7}{RGB}{55, 178, 77}
\definecolor{green-8}{RGB}{47, 158, 68}
\definecolor{green-9}{RGB}{43, 138, 62}

\definecolor{lime-0}{RGB}{244, 252, 227}
\definecolor{lime-1}{RGB}{233, 250, 200}
\definecolor{lime-2}{RGB}{216, 245, 162}
\definecolor{lime-3}{RGB}{192, 235, 117}
\definecolor{lime-4}{RGB}{169, 227, 75}
\definecolor{lime-5}{RGB}{148, 216, 45}
\definecolor{lime-6}{RGB}{130, 201, 30}
\definecolor{lime-7}{RGB}{116, 184, 22}
\definecolor{lime-8}{RGB}{102, 168, 15}
\definecolor{lime-9}{RGB}{92, 148, 13}

\definecolor{yellow-0}{RGB}{255, 249, 219}
\definecolor{yellow-1}{RGB}{255, 243, 191}
\definecolor{yellow-2}{RGB}{255, 236, 153}
\definecolor{yellow-3}{RGB}{255, 224, 102}
\definecolor{yellow-4}{RGB}{255, 212, 59}
\definecolor{yellow-5}{RGB}{252, 196, 25}
\definecolor{yellow-6}{RGB}{250, 176, 5}
\definecolor{yellow-7}{RGB}{245, 159, 0}
\definecolor{yellow-8}{RGB}{240, 140, 0}
\definecolor{yellow-9}{RGB}{230, 119, 0}

\definecolor{orange-0}{RGB}{255, 244, 230}
\definecolor{orange-1}{RGB}{255, 232, 204}
\definecolor{orange-2}{RGB}{255, 216, 168}
\definecolor{orange-3}{RGB}{255, 192, 120}
\definecolor{orange-4}{RGB}{255, 169, 77}
\definecolor{orange-5}{RGB}{255, 146, 43}
\definecolor{orange-6}{RGB}{253, 126, 20}
\definecolor{orange-7}{RGB}{247, 103, 7}
\definecolor{orange-8}{RGB}{232, 89, 12}
\definecolor{orange-9}{RGB}{217, 72, 15}


% --------------------------------------------------------------------------
% Theorem-like environments
% --------------------------------------------------------------------------

% One skip above each environment's name and below the bottom of its box,
% so everything sits on a common vertical grid.
\newskip\ea@skip
\ea@skip=\medskipamount

% Fully boxed, for theorem/lemma/etc.
\mdfdefinestyle{thmstyle}{%
	topline=true,%
	bottomline=true,%
	leftline=true,%
	rightline=true,%
	linewidth=1pt,%
	linecolor=gray-9,%
	innertopmargin=8pt,%
	innerbottommargin=8pt,%
	innerleftmargin=8pt,%
	innerrightmargin=8pt,%
	skipabove=\smallskipamount,%
	skipbelow=\ea@skip,%
	nobreak=false%
}

\mdfdefinestyle{unthmstyle}{%
	topline=true,%
	bottomline=true,%
	leftline=true,%
	rightline=true,%
	linewidth=1pt,%
	linecolor=gray-9,%
	innertopmargin=8pt,%
	innerbottommargin=8pt,%
	innerleftmargin=8pt,%
	innerrightmargin=8pt,%
	skipabove=\smallskipamount,%
	skipbelow=\ea@skip,%
	nobreak=false%
}

% Just a rule down the left, for definition/question.
\mdfdefinestyle{defstyle}{%
	topline=false,%
	bottomline=false,%
	rightline=false,%
	leftline=true,%
	linewidth=0.75ex,%
	linecolor=gray-9,%
	innertopmargin=0pt,%
	innerbottommargin=0pt,%
	innerleftmargin=8pt,%
	innerrightmargin=0pt,%
	skipabove=\ea@skip,%
	skipbelow=\ea@skip,%
	nobreak=false%
}

% Each numbers on its own; definition and question stay unnumbered.
\newcounter{theorem}
\newcounter{lemma}
\newcounter{proposition}
\newcounter{corollary}
\newcounter{conjecture}

% Heading for the boxed environments: "<Name> <n>" with an optional title.
% \needspace keeps the heading from being orphaned above its box at a
% page break.
\newcommand{\ea@thmheader}[3]{%
	\def\ea@thmtitle{#2}%
	\needspace{6\baselineskip}%
	\par\vspace{\ea@skip}\noindent
	{\large\sffamily\bfseries\color{gray-9}#1~\csname the#3\endcsname}%
	\ifx\ea@thmtitle\@empty\else
		\hspace{2em}{\large\normalfont\sffamily\color{gray-9}#2}%
	\fi
	\par\nobreak\smallskip
}

% Unnumbered variant of \ea@thmheader: same look, but no counter is
% printed (and none is stepped), for the "*" environments below.
\newcommand{\ea@thmheaderstar}[2]{%
	\def\ea@thmtitle{#2}%
	\needspace{6\baselineskip}%
	\par\vspace{\ea@skip}\noindent
	{\large\sffamily\bfseries\color{gray-9}#1}%
	\ifx\ea@thmtitle\@empty\else
		\hspace{2em}{\large\normalfont\sffamily\color{gray-9}#2}%
	\fi
	\par\nobreak\smallskip
}

\newenvironment{theorem}[1][]{%
	\refstepcounter{theorem}\ea@thmheader{Theorem}{#1}{theorem}%
	\begin{mdframed}[style=thmstyle]\itshape
}{\end{mdframed}}

\newenvironment{theorem*}[1][]{%
	\ea@thmheaderstar{Theorem}{#1}%
	\begin{mdframed}[style=unthmstyle]\itshape
}{\end{mdframed}}

\newenvironment{lemma}[1][]{%
	\refstepcounter{lemma}\ea@thmheader{Lemma}{#1}{lemma}%
	\begin{mdframed}[style=thmstyle]\itshape
}{\end{mdframed}}

\newenvironment{proposition}[1][]{%
	\refstepcounter{proposition}\ea@thmheader{Proposition}{#1}{proposition}%
	\begin{mdframed}[style=thmstyle]\itshape
}{\end{mdframed}}

\newenvironment{corollary}[1][]{%
	\refstepcounter{corollary}\ea@thmheader{Corollary}{#1}{corollary}%
	\begin{mdframed}[style=thmstyle]\itshape
}{\end{mdframed}}

\newenvironment{conjecture}[1][]{%
	\refstepcounter{conjecture}\ea@thmheader{Conjecture}{#1}{conjecture}%
	\begin{mdframed}[style=thmstyle]\itshape
}{\end{mdframed}}

\newenvironment{definition}[1][]{%
	\def\definition@title{#1}%
	\begin{mdframed}[style=defstyle]%
	\noindent{\sffamily\bfseries\color{gray-9}%
		Definition%
		\ifx\definition@title\@empty\else:\hspace{1ex}\definition@title\fi}%
	\par\smallskip\noindent
}{\end{mdframed}}

\newenvironment{question}[1][]{%
	\def\question@title{#1}%
	\begin{mdframed}[style=defstyle]%
	\noindent{\sffamily\bfseries\color{gray-9}%
		Question%
		\ifx\question@title\@empty\else:\hspace{1ex}\question@title\fi}%
	\par\smallskip\noindent
}{\end{mdframed}}

% Examples run in the text rather than in a box, with a small-caps label.
\newcounter{example}

\newenvironment{example}[1][]{%
	\def\ea@exampletitle{#1}%
	\refstepcounter{example}%
	\par\vspace{\ea@skip}\noindent
	{\normalsize\sffamily\bfseries\color{gray-9}EXAMPLE~\theexample}%
	\ifx\ea@exampletitle\@empty\else
		\hspace{2em}{\normalsize\normalfont\sffamily\color{gray-9}\ea@exampletitle}%
	\fi
	\par\smallskip\noindent\ignorespaces
}{\par\vspace{\ea@skip}}

% Proof: the optional argument (e.g. "of \cref{thm:foo}") sits inline next
% to the PROOF label in the same style.
\newenvironment{proof}[1][]{%
	\def\ea@prooftitle{#1}%
	\par\vspace{\ea@skip}\noindent
	\textbf{\sffamily PROOF\ifx\ea@prooftitle\@empty\else\ \ea@prooftitle\fi}%
	\quad\ignorespaces
}{\hfill$\blacksquare$\par\vspace{\ea@skip}}

\newcommand{\qedhere}{}


% --------------------------------------------------------------------------
% Page layout
% --------------------------------------------------------------------------

% Running header: document title on odd pages, current section on even
% pages, page number at the right, rule on every page.  \maketitle switches
% the title page to an empty style.
\providecommand{\sectionmark}[1]{}
\renewcommand{\sectionmark}[1]{\markright{#1}}

\newcommand{\ea@runningtitle}{\ifodd\value{page}\@title\else\rightmark\fi}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[C]{\small\sffamily\ea@runningtitle}
\fancyhead[R]{\small\sffamily\bfseries\thepage}
\renewcommand{\headrulewidth}{1pt}
\setlength{\headheight}{14pt}

% \subtitle{...} sets a second line under the title, printed in a lighter
% grey below \@title.  Empty by default, so \maketitle skips it entirely.
\newcommand{\@subtitle}{}
\newcommand{\subtitle}[1]{\renewcommand{\@subtitle}{#1}}

\renewcommand{\maketitle}{%
	\thispagestyle{empty}%
	\noindent{\Huge\sffamily\color{black}\@title}\par
	\ifx\@subtitle\@empty\else
		\vspace{1\baselineskip}%
		\noindent{\Large\sffamily\color{gray-7}\@subtitle}\par
	\fi
	\vspace{2\baselineskip}%
}

% Headings are unnumbered throughout.
\setcounter{secnumdepth}{-2}

\titleformat{\section}[hang]
{\Large\sffamily\bfseries\color{black}}
{\thesection\enspace}
{0pt}
{}
[\vspace{-12pt}\rule{\linewidth}{1pt}]
\titlespacing*{\section}{0pt}{1.5\baselineskip}{0.75\baselineskip}

\titleformat{\subsection}[hang]
{\large\sffamily\bfseries\color{black}}
{\thesubsection\enspace}
{0pt}
{}
[\vspace{0pt}]
\titlespacing*{\subsection}{0pt}{\baselineskip}{0.5\baselineskip}

% Subsubsections match, one size down, and run into the following text.
\titleformat{\subsubsection}[runin]
{\normalsize\sffamily\bfseries\color{black}}
{\thesubsubsection\enspace}
{0pt}
{}
\titlespacing*{\subsubsection}{0pt}{0.75\baselineskip}{1em}

\AtBeginDocument{\color{gray-9}}


% --------------------------------------------------------------------------
% Shorthands
% --------------------------------------------------------------------------

\newcommand{\defeq}{\mathrel{\smash{\stackrel{\text{\tiny def}}{=}}}}
\newcommand{\ie}{{\slshape i.\,e.}}

% Emphasis is bold sans here, to sit with the heading style.
\renewcommand{\emph}[1]{{\bfseries\sffamily\boldmath\color{gray-9}#1}}

\newcommand{\definemathbb}[1]{\csdef{#1}{\mathbb{#1}}}
\forcsvlist{\definemathbb}{N,Z,Q,R,C,F,E}