cdsc-paper.sty, cdsc-memo.sty: build headings without titlesec
The tagging code hooks \@startsection to emit the H1/H2/H3 tags that a screen reader navigates by. titlesec replaces \section wholesale rather than going through that hook, so every heading vanished from the structure tree --- with no error to say so, which is why this went unnoticed. titling separately left an unclosed trivlist behind its \flushleft declarations, producing "the number of automatic begin and end text-unit para hooks differ" and a mis-nested tree. Both files now style headings through \@startsection and the title block through \@maketitle, using the class's own hooks. The style argument of \@startsection is applied to the whole heading, so the memo's uppercase headings append \MakeUppercase to it; the tagging code wraps the section number in \NoCaseChange so the number is left alone. Vertical spacing was matched against the previous output page by page: the memo now renders identically bar one heading a pixel off, and the paper's title block lands within two pixels. datetime is dropped from cdsc-paper.sty. Only \today was ever used from it and that is built in. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,18 +1,23 @@
|
||||
% Article-class styles and page layout for CDSC paper documents.
|
||||
%
|
||||
% This file replaces the older cdsc-memoir.sty. It targets the
|
||||
% standard `article' class so the LaTeX tagging-project can produce
|
||||
% standard `article' class so the LaTeX tagging project can produce
|
||||
% tagged, accessible PDFs --- memoir is currently incompatible with
|
||||
% that work. The look-and-feel is kept as close to the previous
|
||||
% cdsc-article chapterstyle as is practical.
|
||||
%
|
||||
% Headings and the title block are built from the article class's own
|
||||
% \@startsection and \@maketitle hooks rather than from titlesec and
|
||||
% titling. The tagging code hooks into \@startsection to emit the H1,
|
||||
% H2, and H3 tags a screen reader navigates by; titlesec bypasses that
|
||||
% hook, so loading it silently produces a PDF with no headings in the
|
||||
% structure tree. See the Accessibility 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{datetime}
|
||||
\usepackage{xcolor}
|
||||
|
||||
%%% Page styles (replaces memoir's \makepagestyle / \makeevenhead etc.)
|
||||
@@ -45,21 +50,39 @@
|
||||
|
||||
\pagestyle{cdsc-page}
|
||||
|
||||
%%% Section heading styles (replaces memoir's \setsecheadstyle etc.)
|
||||
\usepackage{titlesec}
|
||||
%%% Section heading styles.
|
||||
%%%
|
||||
%%% Each heading is declared through \@startsection, which takes:
|
||||
%%% {name}{level}{indent}{beforeskip}{afterskip}{style}
|
||||
%%% A negative beforeskip suppresses the paragraph indent that would
|
||||
%%% otherwise follow the heading; a negative afterskip makes the
|
||||
%%% heading run into the paragraph text rather than sit on its own
|
||||
%%% line. The style argument receives the whole heading as its
|
||||
%%% argument, so a case-changing command may be appended to it.
|
||||
|
||||
% Sections: large small caps; period after the number
|
||||
\titleformat{\section}
|
||||
{\large\scshape}{\thesection.}{0.5em}{}
|
||||
\titlespacing*{\section}{0pt}{*2}{1.7ex}
|
||||
\makeatletter
|
||||
|
||||
% Sections: large small caps
|
||||
\renewcommand\section{\@startsection{section}{1}{\z@}%
|
||||
{-1.8ex \@plus -1ex \@minus -.2ex}%
|
||||
{1.7ex \@plus .2ex}%
|
||||
{\large\scshape}}
|
||||
|
||||
% Subsections: italic
|
||||
\titleformat{\subsection}
|
||||
{\normalsize\itshape}{\thesubsection.}{0.5em}{}
|
||||
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
|
||||
{-3.25ex \@plus -1ex \@minus -.2ex}%
|
||||
{1.5ex \@plus .2ex}%
|
||||
{\normalsize\itshape}}
|
||||
|
||||
% Subsubsections: small bold, runin (matches memoir's negative skip behavior)
|
||||
\titleformat{\subsubsection}[runin]
|
||||
{\small\bfseries}{\thesubsubsection.}{0.5em}{}[\hskip 0.5em]
|
||||
% Subsubsections: small bold, run in to the following paragraph
|
||||
% (the negative afterskip is what makes it run in)
|
||||
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
|
||||
{-3.25ex \@plus -1ex \@minus -.2ex}%
|
||||
{-0.5em}%
|
||||
{\small\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 numbering at the section level (matches the
|
||||
% memoir template's default of \setsecnumdepth{chapter}). To enable
|
||||
@@ -68,23 +91,37 @@
|
||||
\setcounter{secnumdepth}{0}
|
||||
% \setcounter{secnumdepth}{2}
|
||||
|
||||
%%% Title block (titling package replaces memoir's title hooks)
|
||||
\usepackage{titling}
|
||||
|
||||
% Title flush left, italic, large
|
||||
\pretitle{\flushleft\LARGE\itshape}
|
||||
\posttitle{\par\vskip 0.5em}
|
||||
\preauthor{\flushleft\large\lineskip 1em}
|
||||
\postauthor{\par\lineskip 1em}
|
||||
\predate{\flushleft\footnotesize\vspace{0.65em}}
|
||||
\postdate{\par\vskip 1em}
|
||||
|
||||
%%% Title block: flush left, italic title, author below it.
|
||||
%%
|
||||
%% \published{...}: a note about the publication status, printed in
|
||||
%% small type at the very top of the title block. Use this for
|
||||
%% draft/working-paper notices.
|
||||
\newcommand{\puB}{}
|
||||
\newcommand{\published}[1]{\gdef\puB{#1}}
|
||||
\renewcommand{\maketitlehooka}{\par\noindent\footnotesize\puB}
|
||||
|
||||
% \raggedright rather than \flushleft: the flushleft environment is a
|
||||
% trivlist, and starting one as a bare declaration leaves a list open
|
||||
% in the structure tree. That produces "the number of automatic begin
|
||||
% and end text-unit para hooks differ" and a mis-nested PDF.
|
||||
% The vertical skips reproduce what titling's \pretitle/\posttitle,
|
||||
% \preauthor/\postauthor, and \predate/\postdate produced. The date
|
||||
% slot keeps its space even when \date{} is empty, which is what the
|
||||
% previous title block did and what the template's spacing assumes.
|
||||
\renewcommand{\@maketitle}{%
|
||||
\null
|
||||
\vskip 2em%
|
||||
\par\noindent\footnotesize\puB\par
|
||||
\vskip 0.79em%
|
||||
{\raggedright\LARGE\itshape\@title\par}%
|
||||
\vskip 1.04em%
|
||||
{\raggedright\large\lineskip 1em\@author\par}%
|
||||
\vskip 0.79em%
|
||||
{\raggedright\footnotesize\@date\par}%
|
||||
\vskip 1em%
|
||||
\par\vskip 2.44em%
|
||||
}
|
||||
|
||||
\makeatother
|
||||
|
||||
%%% Abstract: runin style ("**Abstract:** the quick brown fox..."),
|
||||
%%% indented from both margins (via the quote environment, which gives
|
||||
|
||||
Reference in New Issue
Block a user