Skip to content

PDF Styling through LaTeX and KOMA‐Script

Liz Dobbins edited this page Jun 14, 2024 · 2 revisions

Original Goal

As requested by Gwen, to make a PDF of AETR that is attractive enough to distribute to legislators.

Issues that Complicate Achieving This

Each of the issues will be described in the following sections, but here is a rundown

  1. Instructing Quarto to render the markdown as PDF
  2. Interactive vs Static graphs
  3. Styling the result
  4. Irritants
  • Tables = blech
  • Footnotes

Quarto Rendering

PDF Basics covers this pretty well.

  • You need to install Tex with quarto install tinytex. PDF Engines describes the various distributions and compilation engines that work with Pandoc, but we will stick with the default
  • You can manually render with quarto render --to pdf
  • Automatic rendering is enabled by adding a pdf: section to _quarto.yml. See the docs for details.
  • If you would like a link to the PDF added to the web book, that is downloads: [pdf] in _quarto.yml. That is in Customizing Book Output

Interactive/static Figures

Our original plotting language was OJS which seemed so cool! However, ojs figures are rendered by the browser when the HTML pages are viewed - not by Quarto. So the rendered PDF only has code - not the figures. Quarto "recommends" to print pages from the browser to PDF files = twisted. In 2022, the prediction was that adding ojs rendering would be implemented in 3-9 months.

Also:

So we had to abandon OJS if we want to have figures in the PDF, and we have to use R for plotting because we need conditional execution for ggplot interactivity for the web version and static plots for the PDF

Final Solution

Fill in details when we figure it out.

Styling in PDF

documentclass

In the format section of _quarto.yml, you can specify the documentclass that sets the basic format of the PDF. Find info in

To summarize, Quarto uses KOMA Script document classes by default, which is basically an extension to LaTeX. koma-script includes classes that include these qualities:

  • scrbook: Book with a header on every page, 2-sided, typesetting, chapters
  • scrreprt: Report for long articles like theses (with optional 2-sided)
  • scrartcl: Articles with no chapters and the title is not a separate page. Render will fail with chapters.
  • scrlttr2: Letter ... whatever
  • slides?

LaTeX overrides

The guiding light for LaTex overrides is https://cameronpatrick.com/post/2023/07/quarto-thesis-formatting/

To be filled in ...

Irritants

Tables

Footnotes