% =============================================================================
% preamble.tex — Differential Equations Handbook
% =============================================================================
% Complete preamble: packages, theorem styles, tcolorbox environments,
% custom macros, and configuration for a 14-chapter handbook.
% =============================================================================

\documentclass[10pt,a4paper]{article}

% ---------------------------------------------------------------------------
% Geometry
% ---------------------------------------------------------------------------
\usepackage[margin=0.75in]{geometry}

% ---------------------------------------------------------------------------
% Math packages
% ---------------------------------------------------------------------------
\usepackage{mathtools}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{bm}
\usepackage{empheq}

% ---------------------------------------------------------------------------
% Colors and boxes
% ---------------------------------------------------------------------------
\usepackage[svgnames]{xcolor}
\usepackage[most]{tcolorbox}

% ---------------------------------------------------------------------------
% Nomenclature (notation glossary)
% ---------------------------------------------------------------------------
\usepackage{nomencl}
\makenomenclature
\setlength{\nomlabelwidth}{2.5cm}
\setlength{\nomitemsep}{2pt}

% ---------------------------------------------------------------------------
% Tables
% ---------------------------------------------------------------------------
\usepackage{booktabs}

% ---------------------------------------------------------------------------
% Graphics
% ---------------------------------------------------------------------------
\usepackage{graphicx}

% ---------------------------------------------------------------------------
% TikZ
% ---------------------------------------------------------------------------
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{patterns}
\usetikzlibrary{decorations.markings}

% ---------------------------------------------------------------------------
% Hyperref (loaded before cleveref)
% ---------------------------------------------------------------------------
\usepackage[colorlinks=true,
            linkcolor=MidnightBlue,
            urlcolor=Navy,
            citecolor=RoyalBlue,
            breaklinks=true]{hyperref}

% ---------------------------------------------------------------------------
% Cross-referencing (must be after hyperref)
% ---------------------------------------------------------------------------
\usepackage[capitalize]{cleveref}

% =============================================================================
% Theorem styles (amsthm)
% =============================================================================
% Number theorems, definitions, and remarks per chapter (section).

\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}

\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}

\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}

% =============================================================================
% tcolorbox environments
% =============================================================================

% Worked Example — blue frame
\newtcolorbox{workedexample}{
  breakable,
  colframe=SteelBlue,
  colback=LightSteelBlue!15,
  coltitle=white,
  fonttitle=\bfseries,
  title=Worked Example,
  boxrule=0.6pt,
  arc=2pt,
  left=6pt, right=6pt, top=4pt, bottom=4pt
}

% Exercise — gray frame
\newtcolorbox{exercise}{
  breakable,
  colframe=Gray,
  colback=LightGray!10,
  coltitle=white,
  fonttitle=\bfseries,
  title=Exercise,
  boxrule=0.5pt,
  arc=2pt,
  left=6pt, right=6pt, top=4pt, bottom=4pt
}

% Key Result — gold/yellow frame
\newtcolorbox{keyresult}{
  breakable,
  colframe=Goldenrod,
  colback=LemonChiffon!25,
  coltitle=black,
  fonttitle=\bfseries,
  title=Key Result,
  boxrule=0.8pt,
  arc=2pt,
  left=6pt, right=6pt, top=4pt, bottom=4pt
}

% Hint — green frame
\newtcolorbox{hintbox}{
  breakable,
  colframe=ForestGreen,
  colback=Honeydew!40,
  coltitle=white,
  fonttitle=\bfseries,
  title=Hint,
  boxrule=0.6pt,
  arc=2pt,
  left=6pt, right=6pt, top=4pt, bottom=4pt
}

% =============================================================================
% Custom macros
% =============================================================================

% Differentials
\newcommand{\diff}{\mathrm{d}}
\newcommand{\dd}{\mathrm{d}}

% Partial derivative shorthand
\newcommand{\pd}[2]{\frac{\partial #1}{\partial #2}}

% Number sets
\newcommand{\R}{\mathbb{R}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\C}{\mathbb{C}}

% Operators
% Note: \Re and \Im are already provided by amsmath; no need to redefine.
\DeclareMathOperator{\tr}{tr}
\DeclareMathOperator{\detop}{det}
\DeclareMathOperator{\spanop}{span}
\DeclareMathOperator{\kerop}{ker}
\DeclareMathOperator{\rankop}{rank}

% =============================================================================
% Additional setup
% =============================================================================

% Table of contents depth
\setcounter{tocdepth}{2}

% Cleveref naming
\crefname{theorem}{Theorem}{Theorems}
\crefname{lemma}{Lemma}{Lemmas}
\crefname{proposition}{Proposition}{Propositions}
\crefname{corollary}{Corollary}{Corollaries}
\crefname{definition}{Definition}{Definitions}
\crefname{remark}{Remark}{Remarks}
\crefname{equation}{equation}{equations}
\crefname{section}{section}{sections}
\crefname{figure}{figure}{figures}
\crefname{table}{table}{tables}

% =============================================================================
% End of preamble.tex
% =============================================================================
