% formatting.sty — Custom commands and formatting for wp1_report_to_test
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{styles/formatting}[2025/12/10 Formatting for WP1 Report]

% --- Paragraph spacing ---
\makeatletter
\@ifundefined{KOMAClassName}{%
  \IfFileExists{parskip.sty}{%
    \usepackage{parskip}
  }{%
    \setlength{\parindent}{0pt}
    \setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{%
  \KOMAoptions{parskip=half}}
\makeatother

% --- List spacing ---
\providecommand{\tightlist}{%
  \setlength{\itemsep}{3pt}\setlength{\parskip}{2pt}}

% --- Pandoc image scaling ---
\makeatletter
\newsavebox\pandoc@box
\newcommand*\pandocbounded[1]{%
  \sbox\pandoc@box{#1}%
  \Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
  \Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
  \ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi
  \ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
  \else\usebox{\pandoc@box}%
  \fi%
}
\def\fps@figure{htbp}
\makeatother

% --- Emergency stretch ---
\setlength{\emergencystretch}{3em}

\usepackage{tabularx}

% --- Section numbering ---
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}

% --- Unnumbered table counter (pandoc) ---
\newcounter{none}

% --- Header / Footer ---
\usepackage{fancyhdr}
\setlength{\headheight}{28pt}
\pagestyle{fancy}
\fancyhf{}  % clear all
\fancyhead[C]{-- \thepage{} --\\SG\studyGroup{}-TD\tdNumber/WP\workingParty}
\renewcommand{\headrulewidth}{0pt}
\fancypagestyle{plain}{% also apply to section-start pages
  \fancyhf{}
  \fancyhead[C]{-- \thepage{} --\\SG\studyGroup{}-TD\tdNumber/WP\workingParty}
  \renewcommand{\headrulewidth}{0pt}
}
\fancypagestyle{empty}{% cover page: no header/footer
  \fancyhf{}
  \renewcommand{\headrulewidth}{0pt}
}
