% Author: Simon-Pierre Boucher — contact@spboucher.ai
%
% ============================================================================
% PREAMBLE — packages, layout, custom commands (UQO working-paper style)
% ============================================================================

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

% --- Page Layout ---
\usepackage[letterpaper, margin=1in, headheight=15pt]{geometry}
\usepackage{setspace}
\onehalfspacing
\setlength{\parindent}{1.5em}
\setlength{\parskip}{0pt}

% --- Typography ---
\usepackage{newtxtext,newtxmath}
\usepackage{amsmath,amsfonts}
\let\Bbbk\relax
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{microtype}

% --- Tables ---
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{tabularx}
\usepackage{array}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{adjustbox}
\usepackage{siunitx}
\usepackage{dcolumn}

% --- Figures ---
\usepackage{graphicx}
\graphicspath{{../figures/}{.}}
\usepackage[
  font       = small,
  labelfont  = bf,
  labelsep   = period,
  skip       = 8pt,
  justification = justified,
  singlelinecheck = false
]{caption}
\usepackage{subcaption}
\usepackage{float}
\usepackage{pdflscape}

% --- Colors & Links ---
\usepackage[dvipsnames]{xcolor}
\usepackage[bookmarks, bookmarksnumbered]{hyperref}
\hypersetup{
  colorlinks  = true,
  linkcolor   = NavyBlue,
  citecolor   = NavyBlue,
  urlcolor    = NavyBlue,
}

% --- Bibliography ---
\usepackage[round, authoryear, comma]{natbib}
\setcitestyle{aysep={,}}
\bibliographystyle{apalike}

% --- Headers & Footers ---
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\small\itshape Semantic Embeddings and Hedonic Pricing}
\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}{}

% --- Appendix Support ---
\usepackage[toc, page]{appendix}
\usepackage{enumitem}
\usepackage{etoolbox}

% --- Custom Column Types ---
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{d}[1]{D{.}{.}{#1}}

% --- Custom Commands ---
\newcommand{\sym}[1]{\ensuremath{^{#1}}}
\newcommand{\stmark}[1]{\rlap{\textsuperscript{#1}}}
\DeclareMathOperator*{\plim}{plim}
\newcommand{\E}{\mathbb{E}}
\newcommand{\Var}{\mathrm{Var}}
\newcommand{\Cov}{\mathrm{Cov}}
\newcommand{\Corr}{\mathrm{Corr}}
\newcommand{\se}{\mathrm{s.e.}}
\newcommand{\tr}{\mathrm{tr}}
\newcommand{\rank}{\mathrm{rank}}
\newcommand{\diag}{\mathrm{diag}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\eps}{\varepsilon}
\newcommand{\bfbeta}{\boldsymbol{\beta}}
\newcommand{\bfgamma}{\boldsymbol{\gamma}}
\newcommand{\bfalpha}{\boldsymbol{\alpha}}
\newcommand{\bfdelta}{\boldsymbol{\delta}}
\newcommand{\bftheta}{\boldsymbol{\theta}}
\newcommand{\bfSigma}{\boldsymbol{\Sigma}}
\newcommand{\bfOmega}{\boldsymbol{\Omega}}
\newcommand{\bfX}{\mathbf{X}}
\newcommand{\bfY}{\mathbf{Y}}
\newcommand{\bfy}{\mathbf{y}}
\newcommand{\bfe}{\mathbf{e}}
\newcommand{\bfs}{\mathbf{s}}
\newcommand{\iid}{\overset{\mathrm{iid}}{\sim}}
\newcommand{\pto}{\overset{p}{\to}}
\newcommand{\dto}{\overset{d}{\to}}
\newcommand{\ols}{\mathrm{OLS}}
\newcommand{\iv}{\mathrm{IV}}
\newcommand{\gmm}{\mathrm{GMM}}
\newcommand{\mle}{\mathrm{MLE}}
\newcommand{\pval}{\textit{p}-value}
\newcommand{\tstat}{\textit{t}-statistic}
\newcommand{\fstat}{\textit{F}-statistic}
\newcommand{\tablenote}[1]{\begin{minipage}{\linewidth}\footnotesize #1\end{minipage}}
\newcommand{\signote}{*** $p < 0.001$; ** $p < 0.01$; * $p < 0.05$.}
