18
0

paper_template (knitr): port to master's article + lualatex stack

Bring the knitr paper template up to date with the typography work
on master. The preamble now mirrors master's paper_template/text.tex:

- \DocumentMetadata{pdfstandard=ua-2} + tagpdf instead of the old
  memoir / pdfmanagement-only setup
- article class with cdsc-paper.sty (the article-class replacement
  for cdsc-memoir.sty added on master)
- fontspec with EB Garamond and TeX Gyre Heros, plus
  \defaultfontfeatures{Ligatures=TeX} so --, ---, ``, '' work
- Makefile builds with latexmk -lualatex instead of -pdf

The knitr-specific bits are preserved unchanged:

- <<init>>= chunk for knit_hooks and resources/preamble.R
- <<test_table>>= chunk demonstrating kable inside a table float
- %.tex: %.Rtex pattern rule for knit() in the Makefile

verapdf --flavour ua2: 0 failures, 1723 passed rules.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-11 09:47:22 -07:00
parent 887dfdfa8b
commit a3e469ca3f
4 changed files with 144 additions and 272 deletions

View File

@@ -1,14 +1,17 @@
\documentclass[12pt]{memoir}
% Tagged PDF (PDF/UA-2) accessibility setup. The article class works
% with the LaTeX tagging-project, so we use the full \DocumentMetadata
% path here.
\DocumentMetadata{
pdfversion=2.0,
pdfstandard=ua-2,
lang=en-US,
}
\usepackage{cdsc-memoir}
% there are two chapter styles: cdsc-article and cdsc-memo
% memo assumes that you remove the "\\" and the email address from the
% \author field below as well as that you will comment out the
% \published tag
\chapterstyle{cdsc-article}
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{wrapfig}
\usepackage{cdsc-paper}
\usepackage{tagpdf}
\tagpdfsetup{activate-all}
<<init, echo=FALSE>>=
knit_hooks$set(document = function(x) {
@@ -21,9 +24,14 @@ opts_chunk$set(fig.path="figures/knitr-")
source("resources/preamble.R")
@
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage[garamond]{mathdesign}
\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{EB Garamond}
\setsansfont{TeX Gyre Heros}
\usepackage{wrapfig}
\usepackage[letterpaper,left=1.65in,right=1.65in,top=1.3in,bottom=1.2in]{geometry}
@@ -39,8 +47,15 @@ source("resources/preamble.R")
% 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}
urlcolor=Blue, unicode=true,
pdftitle={Title},
pdfauthor={Your Name},
pdflang={en-US},
pdfdisplaydoctitle=true}
% list of footnote symbols for \thanks{}
\makeatletter
@@ -50,7 +65,7 @@ source("resources/preamble.R")
\makeatother
\newcommand*\samethanks[1][\value{footnote}]{\footnotemark[#1]}
% add bibliographic stuff
% add bibliographic stuff
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[natbib=true, style=apa, backend=biber]{biblatex}
@@ -60,15 +75,11 @@ source("resources/preamble.R")
\defbibheading{secbib}[\bibname]{%
\section*{#1}%
\markboth{#1}{#1}%
\baselineskip 14.2pt%
\prebibhook}
\baselineskip 14.2pt}
\def\citepos#1{\citeauthor{#1}'s (\citeyear{#1})}
\def\citespos#1{\citeauthor{#1}' (\citeyear{#1})}
% memoir function to take out of the space out of the whitespace lists
\firmlists
% 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:
@@ -117,7 +128,7 @@ fox jumps over the lazy dog.
% 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).
% can become. The following line is 3 alphabets (73 characters).
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
@@ -137,14 +148,6 @@ 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}.
\begin{table}
\centering
<<test_table, echo=FALSE>>=
@@ -170,38 +173,6 @@ 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}.
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}.
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}.
% bibliography here
\setcounter{biburlnumpenalty}{9001}
\printbibliography[title = {References}, heading=secbib]
@@ -209,4 +180,4 @@ fox jumps over the lazy dog \citep{989866}.
\end{document}
% LocalWords:
% LocalWords: