bird
bird

Reputation: 3294

Why do affiliations not show up anywhere in the pdf output of quarto?

In the yaml of a quarto document I have:

---
title: "Hey!"
author:
  - name: Birdy Bird
    affiliations:
      - University of Birds
      - University of Hummingbirds
format: pdf
editor: visual
---

When I render this file using Rstudio IDE, I get:

enter image description here

I was expecting the affiliations with their numbers (e.g. 1, 2 as superscripts) to show up somewhere.

R version:

> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.2.2 tools_4.2.2   

Rstudio version

> rstudioapi::versionInfo()
$citation

To cite RStudio in publications use:

  Posit team (2022). RStudio: Integrated Development Environment for R. Posit Software, PBC, Boston, MA. URL
  http://www.posit.co/.

A BibTeX entry for LaTeX users is

  @Manual{,
    title = {RStudio: Integrated Development Environment for R},
    author = {{Posit team}},
    organization = {Posit Software, PBC},
    address = {Boston, MA},
    year = {2022},
    url = {http://www.posit.co/},
  }


$mode
[1] "desktop"

$version
[1] ‘2022.12.0.353’

$long_version
[1] "2022.12.0+353"

$release_name
[1] "Elsbeth Geranium"

Quarto version:

> quarto::quarto_version()
[1] ‘1.2.269’

Upvotes: 9

Views: 2705

Answers (2)

Shafee
Shafee

Reputation: 19897

My guess is Quarto's default pdf format does not support author affiliations, since there are no such mentions in quarto's pdf format reference.

And in Quarto docs, Authors & Affiliations discusses ways to access authors and affiliations metadata when creating Journal Article quarto extensions.

However, It's possible to add authors' affiliations nicely using the following LaTeX Partial title.tex which uses latex package authblk for nice formatting and options to control the formatting.

(Make sure to place title.tex and quarto-file.qmd in the same directory)

title.tex

$if(title)$
\title{$title$$if(thanks)$\thanks{$thanks$}$endif$}
$endif$

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

$for(by-author)$
  \author{$by-author.name.literal$}
  $if(by-author.affiliations)$
    $for(by-author.affiliations)$
      \affil{%
        $if(by-author.affiliations.name)$
          $by-author.affiliations.name$
        $endif$
      }
    $endfor$
  $endif$
$endfor$

\date{$date$}

quarto-file.qmd

---
title: "Hey!"
author:
  - name: Birdy Bird
    affiliations:
      - University of Birds
      - University of Hummingbirds
  - name: None
    affiliations:
      - University of SO
      - University of TeX
format: 
  pdf:
    keep-tex: true
    template-partials: 
      - title.tex
    include-in-header:
      text: |
        \usepackage[noblocks]{authblk}
        \renewcommand*{\Authsep}{, }
        \renewcommand*{\Authand}{, }
        \renewcommand*{\Authands}{, }
        \renewcommand\Affilfont{\small}
---

## Quarto

Quarto enables you to weave together content and executable code into a finished
document. To learn more about Quarto see <https://quarto.org>.

affiliations in pdf


Author with multiple affiliation subscript

the key thing to note in this case is that the option affil-id which needs to be a number that will link the authors and their affiliations and it will correspond to the id under the affiliations key.

---
title: "Hey!"
author:
  - name: Birdy Bird
    affil-id: 1,2
  - name: None
    affil-id: 3,4

affiliations: 
  - id: 1
    name: University of Birds
  - id: 2
    name: University of Hummingbirds
  - id: 3
    name: University of TeX
  - id: 4
    name: Unversity of SO
format: 
  pdf:
    keep-tex: true
    template-partials: 
      - title.tex
    include-in-header:
      text: |
        \usepackage[noblocks]{authblk}
        \renewcommand*{\Authsep}{, }
        \renewcommand*{\Authand}{, }
        \renewcommand*{\Authands}{, }
        \renewcommand\Affilfont{\small}
---

## Quarto

Quarto enables you to weave together content and executable code into a finished
document. To learn more about Quarto see <https://quarto.org>.

In this case, use the following title.tex latex partial,

$if(title)$
\title{$title$$if(thanks)$\thanks{$thanks$}$endif$}
$endif$

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

$for(by-author)$
\author$if(it.metadata.affil-id)$[$it.metadata.affil-id$]$endif${$it.name.literal$}
$endfor$

$if(by-affiliation)$
$for(by-affiliation)$
\affil[$it.id$]{$it.name$}
$endfor$
$endif$


\date{$date$}

and then rendering the quarto-file.qmd file as above gives,


Author with multiple affiliation subscript


Explore the authblk docs to know about ways to control affiliations formatting.

Upvotes: 12

PeterBloomingdale
PeterBloomingdale

Reputation: 151

I am facing the the same issue. The HTML output includes author metadata, but the PDF output does not. Apparently this can solve this by including template partials that define the author meta data to include.

In the YAML header you will need:

format:
  pdf:
    keep-tex: true
    template-partials: 
      - _extensions\partials\title.tex

In the title.tex file you need something like:

\title{$title$}

\author{
  $for(by-author)$
    {$by-author.name.literal$} \\
    $for(by-author.affiliations)$
      $it.name$ \\
      $it.country$
    $endfor$ \\
    $if(by-author.email)$\href{mailto:$by-author.email$}{$by-author.email$}$endif$
    \and 
  $endfor$}

\date{$date$}

I had this working in the past, but unfortunately it is no longer working (not sure why)...

More information about template partials can be obtained here: Quarto Template Partials

Templates can be found in the GitHub link here: Quarto GitHub PDF Templates

Upvotes: 4

Related Questions