The merge from master brought in a static demo table and a LaTeX-only
figure example, neither of which suits this branch. This adapts them to
knitr.
\tagpdfsetup{table/header-rows={1}} now sits above the existing kable
table rather than above a hand-written duplicate, which is the case a
reader of this branch actually has: kable emits the column names as a
single header row, so those cells become TH and a screen reader can
announce which column a value belongs to. Verified in the built PDF,
which now carries two TH cells alongside its twelve TD.
The figure example gains the knitr form. A chunk passes its
description through the fig.alt option, which knitr writes into the
\includegraphics call it generates; the file-inclusion form is kept
alongside it for figures that do not come from a chunk. Both are
commented out, so knitr does not try to evaluate a plot of data the
template does not ship.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
240 lines
9.2 KiB
Plaintext
240 lines
9.2 KiB
Plaintext
% Tagged PDF (PDF/UA-2) accessibility setup. The article class works
|
|
% with the LaTeX tagging project, so we use the full \DocumentMetadata
|
|
% path here.
|
|
%
|
|
% tagging=on is what actually builds the structure tree: it loads the
|
|
% kernel code that tags paragraphs, headings, lists, tables, and
|
|
% floats. Declaring pdfstandard=ua-2 on its own only writes the claim
|
|
% into the metadata; without tagging=on the PDF is marked as UA-2 but
|
|
% carries no structure for a screen reader to read. This needs TeX
|
|
% Live 2025 or later --- on Overleaf, set it in Menu > Settings >
|
|
% TeX Live version.
|
|
\DocumentMetadata{
|
|
tagging=on,
|
|
pdfversion=2.0,
|
|
pdfstandard=ua-2,
|
|
lang=en-US,
|
|
}
|
|
|
|
\documentclass[12pt]{article}
|
|
|
|
\usepackage{cdsc-paper}
|
|
|
|
<<init, echo=FALSE>>=
|
|
knit_hooks$set(document = function(x) {
|
|
x <- sub('\\usepackage[]{xcolor}',
|
|
'\\usepackage[dvipsnames]{xcolor}', x, fixed = TRUE)
|
|
x
|
|
})
|
|
opts_chunk$set(fig.path="figures/knitr-")
|
|
|
|
source("resources/preamble.R")
|
|
@
|
|
|
|
\usepackage{fontspec}
|
|
% fontspec disables the classic TeX input ligatures by default
|
|
% (-- => en-dash, --- => em-dash, `` and '' => curly quotes), so
|
|
% re-enable them globally for every font loaded below.
|
|
\defaultfontfeatures{Ligatures=TeX}
|
|
\setmainfont{Libertinus Serif}
|
|
% Mako prefers Adobe Garamond Premier Pro
|
|
% (https://fonts.adobe.com/fonts/garamond-premier-pro). It is a
|
|
% commercial font and is not redistributable, so the templates default
|
|
% to the free Libertinus Serif above. If you have the font installed
|
|
% (e.g., dropped into ~/.fonts/), comment the line above and uncomment
|
|
% the next one. CDSC members can contact Mako (mako@atdot.cc) for the
|
|
% font files.
|
|
% \setmainfont{Garamond Premier Pro}
|
|
\setsansfont{TeX Gyre Heros}
|
|
\usepackage{wrapfig}
|
|
|
|
\usepackage[letterpaper,left=1.65in,right=1.65in,top=1.3in,bottom=1.2in]{geometry}
|
|
|
|
% packages i use in essentially every document
|
|
\usepackage{graphicx}
|
|
\usepackage{enumerate}
|
|
|
|
% packages i use in many documents but leave off by default
|
|
% \usepackage{amsmath, amsthm, amssymb}
|
|
% \usepackage{dcolumn}
|
|
% \usepackage{endfloat}
|
|
|
|
% import and customize urls
|
|
\usepackage[dvipsnames]{xcolor}
|
|
\usepackage[breaklinks]{hyperref}
|
|
|
|
% pdftitle/pdfauthor populate PDF and XMP metadata; keep these in sync
|
|
% with \title{} and \author{} below. UA-2 requires dc:title in XMP.
|
|
\hypersetup{colorlinks=true, linkcolor=Black, citecolor=Black, filecolor=Blue,
|
|
urlcolor=Blue, unicode=true,
|
|
pdftitle={Title},
|
|
pdfauthor={Your Name},
|
|
pdflang={en-US},
|
|
pdfdisplaydoctitle=true}
|
|
|
|
% list of footnote symbols for \thanks{}
|
|
\makeatletter
|
|
\renewcommand*{\@fnsymbol}[1]{\ensuremath{\ifcase#1\or *\or \dagger\or \ddagger\or
|
|
\mathsection\or \mathparagraph\or \|\or **\or \dagger\dagger
|
|
\or \ddagger\ddagger \else\@ctrerr\fi}}
|
|
\makeatother
|
|
\newcommand*\samethanks[1][\value{footnote}]{\footnotemark[#1]}
|
|
|
|
% add bibliographic stuff
|
|
\usepackage[american]{babel}
|
|
\usepackage{csquotes}
|
|
\usepackage[natbib=true, style=apa, backend=biber]{biblatex}
|
|
\addbibresource{refs.bib}
|
|
\DeclareLanguageMapping{american}{american-apa}
|
|
|
|
\defbibheading{secbib}[\bibname]{%
|
|
\section*{#1}%
|
|
\markboth{#1}{#1}%
|
|
\baselineskip 14.2pt}
|
|
|
|
\def\citepos#1{\citeauthor{#1}'s (\citeyear{#1})}
|
|
\def\citespos#1{\citeauthor{#1}' (\citeyear{#1})}
|
|
|
|
% LATEX NOTE: these lines will import vc stuff after running `make vc` which
|
|
% will add version control information to the bottom of each page. This can be
|
|
% useful for keeping track of which version of a document somebody has:
|
|
% \input{vc}
|
|
% \pagestyle{cdsc-page-git}
|
|
|
|
% LATEX NOTE: this alternative line will just input a timestamp at the
|
|
% build process, useful for Overleaf
|
|
% \pagestyle{cdsc-page-overleaf}
|
|
|
|
\begin{document}
|
|
|
|
\setlength{\parskip}{4.5pt}
|
|
% LATEX NOTE: Ideal linespacing is usually said to be between 120-140% the
|
|
% typeface size. So, for 12pt (default in this document, we're looking for
|
|
% somewhere between a 14.4-17.4pt \baselineskip. Single; 1.5 lines; and Double
|
|
% in MSWord are equivalent to ~117%, 175%, and 233%.
|
|
|
|
\baselineskip 16pt
|
|
|
|
\title{Title}
|
|
\author{Your Name\\
|
|
\href{mailto:youremail@uw.edu}{youremail@uw.edu}}
|
|
\date{}
|
|
|
|
\published{\textsc{\textcolor{BrickRed}{This document is an
|
|
unpublished draft.\\ Please do not distribute or cite without
|
|
permission.}}}
|
|
|
|
\maketitle
|
|
|
|
\begin{abstract}
|
|
The quick brown fox jumps over the lazy dog. The quick brown fox jumps
|
|
over the lazy dog. The quick brown fox jumps over the lazy dog. The
|
|
quick brown fox jumps over the lazy dog. The quick brown fox jumps over
|
|
the lazy dog. The quick brown fox jumps over the lazy dog. The quick
|
|
brown fox jumps over the lazy dog. The quick brown fox jumps over the
|
|
lazy dog. The quick brown fox jumps over the lazy dog. The quick brown
|
|
fox jumps over the lazy dog.
|
|
\end{abstract}
|
|
|
|
\section{Section}
|
|
|
|
% LATEX NOTE: This alphabet below is here so we can measure the line-length of
|
|
% different layouts. Typesetters suggest that an average line-length of
|
|
% between 45-90 characters and a rule of thumb for typesetting is that you
|
|
% should be able to fit between 2-3 alphabets on one line. Generally speaking,
|
|
% the shorter the line length, the better -- and the smaller the linespacing
|
|
% can become. The following line is 3 alphabets (73 characters).
|
|
|
|
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
|
|
|
|
The quick brown fox jumps over the lazy dog. The quick brown fox jumps
|
|
over the lazy dog. The quick brown fox jumps over the lazy dog. The
|
|
quick brown fox jumps over the lazy dog. The quick brown fox jumps over
|
|
the lazy dog. The quick brown fox jumps over the lazy dog. The quick
|
|
brown fox jumps over the lazy dog. The quick brown fox jumps over the
|
|
lazy dog. The quick brown fox jumps over the lazy dog. The quick brown
|
|
fox jumps over the lazy dog \citep{989866}.
|
|
|
|
The quick brown fox jumps over the lazy dog. The quick brown fox jumps
|
|
over the lazy dog. The quick brown fox jumps over the lazy dog. The
|
|
quick brown fox jumps over the lazy dog. The quick brown fox jumps over
|
|
the lazy dog. The quick brown fox jumps over the lazy dog. The quick
|
|
brown fox jumps over the lazy dog. The quick brown fox jumps over the
|
|
lazy dog. The quick brown fox jumps over the lazy dog. The quick brown
|
|
fox jumps over the lazy dog \citep{989866}.
|
|
|
|
% ACCESSIBILITY: header-rows tells the tagging code which rows are
|
|
% headers, so their cells become TH rather than TD and a screen reader
|
|
% can announce which column a value belongs to. Without it, a table
|
|
% reads as an undifferentiated grid of numbers. kable puts the column
|
|
% names in a single header row, so {1} is right for the table below;
|
|
% use {1,2} where two rows are headers. Set it for each table, since
|
|
% it applies to the tables that follow it.
|
|
\tagpdfsetup{table/header-rows={1}}
|
|
\begin{table}
|
|
\centering
|
|
<<test_table, echo=FALSE>>=
|
|
kable(form.copy, format="latex")
|
|
@
|
|
\caption{This is a test table. There are \Sexpr{f(nrow(form.copy))} rows in the table.}
|
|
\label{tab:test}
|
|
\end{table}
|
|
|
|
The quick brown fox jumps over the lazy dog. The quick brown fox jumps
|
|
over the lazy dog. The quick brown fox jumps over the lazy dog. The
|
|
quick brown fox jumps over the lazy dog. The quick brown fox jumps over
|
|
the lazy dog. The quick brown fox jumps over the lazy dog. The quick
|
|
brown fox jumps over the lazy dog. The quick brown fox jumps over the
|
|
lazy dog. The quick brown fox jumps over the lazy dog. The quick brown
|
|
fox jumps over the lazy dog \citep{989866}.
|
|
|
|
The quick brown fox jumps over the lazy dog. The quick brown fox jumps
|
|
over the lazy dog. The quick brown fox jumps over the lazy dog. The
|
|
quick brown fox jumps over the lazy dog. The quick brown fox jumps over
|
|
the lazy dog. The quick brown fox jumps over the lazy dog. The quick
|
|
brown fox jumps over the lazy dog. The quick brown fox jumps over the
|
|
lazy dog. The quick brown fox jumps over the lazy dog. The quick brown
|
|
fox jumps over the lazy dog \citep{989866}.
|
|
|
|
\section{Accessible Figures and Tables}
|
|
|
|
Table~\ref{tab:test} above is tagged with a header row. Figures need
|
|
alt text, which is what a screen reader announces in place of the
|
|
image. Describe what the reader is meant to take from the figure
|
|
rather than naming it: "Edit counts rising sharply after 2005" tells
|
|
them something, "Figure 1" does not. The caption is read separately,
|
|
so alt text that repeats it is wasted. These are worked examples;
|
|
delete this section when you start writing.
|
|
|
|
% For a figure generated by a chunk, knitr passes the fig.alt option
|
|
% through to the \includegraphics call it writes:
|
|
%
|
|
% <<edits_plot, echo=FALSE, fig.cap="A caption, read separately from the alt text.", fig.alt="Edit counts by year, rising sharply after 2005">>=
|
|
% plot(year, edits)
|
|
% @
|
|
%
|
|
% For a figure included from a file, put alt= on \includegraphics
|
|
% directly. A purely decorative image takes [artifact] instead, which
|
|
% keeps it out of the reading order entirely:
|
|
%
|
|
% \begin{figure}
|
|
% \centering
|
|
% \includegraphics[width=0.6\linewidth,
|
|
% alt={Edit counts by year, rising sharply after 2005}]{figure.pdf}
|
|
% \caption{A caption, which is read separately from the alt text.}
|
|
% \label{fig:example}
|
|
% \end{figure}
|
|
|
|
% A table used only to position things on the page, rather than to
|
|
% present data, should be marked so assistive software skips its
|
|
% structure: \tagpdfsetup{table/tagging=presentation}
|
|
|
|
% bibliography here
|
|
\setcounter{biburlnumpenalty}{9001}
|
|
\printbibliography[title = {References}, heading=secbib]
|
|
|
|
|
|
\end{document}
|
|
|
|
% LocalWords:
|