Pandoc template help

The files that appear in the template-partials: line of the YAML are Pandoc Templates with LaTeX Pandoc templating

$-- is a Pandoc comment % is a LaTeX comment

Comments

To comment out a line in a pandoc template, use $--.

$-- this is a comment

If statements

$if(subtitle)$ ... $endif$

Here subtitle is true if the YAML has “subtitle:” and false otherwise

$subtitle$ (with $..$) is the value of subtitle in the YAML

$if(subtitle)${\large\textit{$subtitle$}}$endif$ 

prints the subtitle in large text. \large is LaTeX

$if(by-author/allbutlast)$ means if there is more than one author since if there is only one author then there is no “allbutlast” value

$if(by-author/last)$ tests if there is a last author. If there is at least one author, this will be true.

for loops

The basic syntax is $for(mylist)$ ... $sep$ ... $endfor$ where the value after $sep$ specifies what separates each value in the list. Let’s say in your yaml, you have mylist: ["one", "two", "three"].

$for(mylist)${\large{$mylist$}}$sep$ AND $endfor$%

Would put {\large{one}} AND {\large{two}} AND {\large{three}} in your tex file.

Two common ways to have lists in your yaml:

mylist1: ["one", "two", "three"]
mylist2:
  - "one"
  - "two"
  - "three"

Authors and affiliations The Quarto author filter sets up lists of the unique authors and affiliations that you can use. See the title.tex and before-body.tex examples in https://github.com/quarto-journals.

$for(by-author)$%
{\large{$by-author.name.literal$}}$sep${\large{ AND }}
$endfor$%

This is a for loop across all the authors and prints each author name. The $sep$ bit says what to put between the names. In this case it would be AND. So Jane Doe AND Ashkar Kumar

Include other templates

You can include other files in your template partials. Let’s say you have a file called _titlepage.tex. You can include it in another template by putting () after the name of the file:

$_titlepage.tex()$

Make sure to list the file in your yaml. The _ in front of the name is just to help you make sure you don’t accidentally use one of Pandoc’s reserved names (like title.tex).

format:
  pdf:
    documentclass: scrartcl 
    number-sections: true
    template-partials:
      - "before-body.tex"
      - "_titlepage.tex" 

Number appearances

The Pandoc template can number the author affiliations and will figure the duplicates.

$for(by-author)$%
{\large{$by-author.name.literal$}}%
$for(by-author.affiliations)$%
{\textsuperscript{$it.number$}}$sep$\textsuperscript{,}%
$endfor$%
$sep$, %
$endfor$

This is assigning a number to each affiliation name and then adds it as a superscript to the author name. It will figure out the duplicates.