% =============================================================================
% Author: Simon-Pierre Boucher
% Contact: contact@spboucher.ai
% =============================================================================
% Preamble — packages, layout, typography, table/figure setup, custom macros.
% Loaded by main.tex before the metadata block.
% =============================================================================

% --- Encoding & Language ---
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}

% --- Page Layout ---
\usepackage[
  letterpaper,
  top=1in, bottom=1in, left=1in, right=1in,
  headheight=15pt
]{geometry}
\usepackage{setspace}
\onehalfspacing

% --- Typography ---
\usepackage{newtxtext,newtxmath}
\usepackage{microtype}

% --- Math ---
\usepackage{amsmath}
\let\Bbbk\relax
\usepackage{amssymb,amsfonts}
\usepackage{mathtools}

% --- Tables ---
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{threeparttable}
\usepackage{array}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}}

% --- Figures ---
\usepackage{graphicx}
\usepackage{float}
\usepackage[
  font       = small,
  labelfont  = bf,
  labelsep   = period,
  skip       = 6pt,
  justification = justified,
  singlelinecheck = false
]{caption}
\usepackage{subcaption}

% --- Lists ---
\usepackage{enumitem}
\setlist{nosep,leftmargin=*}

% --- Colors & Links ---
\usepackage[dvipsnames,table]{xcolor}
\usepackage[bookmarks, bookmarksnumbered]{hyperref}
\hypersetup{
  colorlinks  = true,
  linkcolor   = NavyBlue,
  citecolor   = NavyBlue,
  urlcolor    = NavyBlue,
  pdfauthor   = {Simon-Pierre Boucher},
  pdftitle    = {Options-Implied Information Content},
  pdfsubject  = {Working Paper WP7},
  pdfkeywords = {option-implied information, realized volatility, HAR-RV, implied correlation, portfolio sorts, Granger causality}
}
\usepackage{cleveref}

% --- Landscape & Rotation ---
\usepackage{pdflscape}

% --- Bibliography (BibTeX via natbib) ---
\usepackage{natbib}
\setcitestyle{authoryear,round,semicolon}
\bibliographystyle{apalike}

% --- Headers & Footers ---
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\small\itshape Options-Implied Information Content}
\fancyhead[R]{\small\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}
\fancypagestyle{plain}{%
  \fancyhf{}
  \fancyfoot[C]{\small\thepage}
  \renewcommand{\headrulewidth}{0pt}
}

% --- Section Formatting ---
\usepackage{titlesec}
\titleformat{\section}{\large\bfseries}{\thesection.}{0.5em}{}
\titleformat{\subsection}{\normalsize\bfseries}{\thesubsection.}{0.5em}{}
\titleformat{\subsubsection}{\normalsize\itshape}{\thesubsubsection.}{0.5em}{}
\titlespacing*{\section}{0pt}{18pt}{8pt}
\titlespacing*{\subsection}{0pt}{12pt}{4pt}
\titlespacing*{\subsubsection}{0pt}{10pt}{3pt}

% --- Footnotes ---
\usepackage[bottom,hang]{footmisc}
\setlength{\footnotemargin}{0.5em}

% --- Appendix ---
\usepackage[title]{appendix}
\usepackage{apptools}
\AtAppendix{%
  \renewcommand{\thetable}{A\arabic{table}}%
  \setcounter{table}{0}%
  \renewcommand{\thefigure}{A\arabic{figure}}%
  \setcounter{figure}{0}%
  \renewcommand{\theequation}{A.\arabic{equation}}%
  \setcounter{equation}{0}%
}

% --- Custom Commands ---
\newcommand{\sym}[1]{\ensuremath{^{#1}}}
\newcommand{\ie}{\textit{i.e.}}
\newcommand{\eg}{\textit{e.g.}}
