% Memo-style page layout for CDSC documents.
%
% Article-class equivalent of the old cdsc-memo chapterstyle that
% lived in cdsc-memoir.sty. Targets the standard `article' class so
% the LaTeX tagging project can produce tagged, accessible PDFs.
%
% Look-and-feel: sans-serif uppercase title and author on a single
% line, sans-serif uppercase section headings, no paragraph indent,
% and a small-caps "page/total" footer.
%
% Headings use the class's own \@startsection hook, not titlesec,
% which breaks tagging. See the Customizing section of the README.
%
% Copyright 2009-2026 Benjamin Mako Hill <mako@atdot.cc>
% Copyright 2008-2009 Kieran Healy <kjhealy@soc.duke.edu>

% Distributed as free software under the GNU GPL v3

\usepackage{lastpage}
\usepackage{xcolor}

%%% Page style: empty header; "page/total" centered in the footer.
\usepackage{fancyhdr}
\setlength{\headheight}{14.5pt}
\addtolength{\topmargin}{-2.5pt}

\fancypagestyle{cdsc-page-memo}{%
  \fancyhf{}%
  \fancyfoot[C]{\scshape\thepage/\pageref*{LastPage}}%
  \renewcommand{\headrulewidth}{0pt}%
}

% Variant with git revision info in the footer (requires the vc package).
\fancypagestyle{cdsc-page-memo-git}{%
  \fancyhf{}%
  \fancyfoot[C]{\texttt{\footnotesize\textcolor{BrickRed}{git revision \VCRevision\ on \VCDateTEX}}}%
  \renewcommand{\headrulewidth}{0pt}%
}

\pagestyle{cdsc-page-memo}

%%% Section headings: sans-serif bold uppercase. \@startsection applies
%%% the style argument to the whole heading, so \MakeUppercase can be
%%% appended; the tagging code wraps the number in \NoCaseChange.

\makeatletter

\renewcommand\section{\@startsection{section}{1}{\z@}%
  {-1.8ex \@plus -1ex \@minus -.2ex}%
  {1pt}%
  {\normalsize\sffamily\bfseries\MakeUppercase}}

\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
  {-1.3ex \@plus -1ex \@minus -.2ex}%
  {1pt}%
  {\small\sffamily\bfseries\MakeUppercase}}

\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
  {-1ex \@plus -1ex \@minus -.2ex}%
  {-0.5em}%
  {\footnotesize\sffamily\bfseries}}

% Period after the section number, when numbering is switched on below
\renewcommand{\@seccntformat}[1]{\csname the#1\endcsname.\hspace{0.5em}}

% By default, suppress section numbering. To enable numbered sections
% and subsections, comment the line below and uncomment the alternative.
\setcounter{secnumdepth}{0}
% \setcounter{secnumdepth}{2}

%%% Title block: "TITLE [...] AUTHOR" on a single line, no date.
%%
%% \published{...}: a note about publication status, printed in small
%% type at the very top of the title block.
\newcommand{\puB}{}
\newcommand{\published}[1]{\gdef\puB{#1}}

\renewcommand{\maketitle}{%
  \par\noindent\footnotesize\puB\par
  {\large\sffamily\bfseries\MakeUppercase{\@title}}\hfill
  {\large\sffamily\MakeUppercase{\@author}}%
  \par\vskip 0.7em%
}

\makeatother

%%% List spacing
\usepackage{enumitem}
\setlist{topsep=0pt, partopsep=0pt}

%%% Caption font
\usepackage{caption}
\captionsetup{font=small}

%%% No paragraph indent (memos use a blank-line paragraph break style).
\setlength{\parindent}{0pt}

%%% Footnote symbol command (for \thanks{} footnotes that should not
%%% have a numeric mark). Use as \symbolfootnote[0]{Footnote text}.
\long\def\symbolfootnote[#1]#2{\begingroup%
  \def\thefootnote{\fnsymbol{footnote}}\footnote[#1]{#2}\endgroup}

\endinput
