Search code examples
rpdflatexpdflatexquarto

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’

Solution

  • 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.