简体   繁体   中英

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:

在此处输入图像描述

I was expecting the affiliations with their numbers (eg 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’

My guess is Quarto's default pdf format does not support author affiliations, since there are no such mentions inquarto'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>.

pdf格式的隶属关系


Author with multiple affiliation subscript

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[$for(by-author.affiliations)$$it.number$$sep$,$endfor$]{$by-author.name.literal$}
$endfor$

$for(by-author)$
$if(by-author.affiliations)$
$for(by-author.affiliations)$
\affil[$it.number$]{$if(by-author.affiliations.name)$$by-author.affiliations.name$$endif$}
$endfor$
$endif$
$endfor$


\date{$date$}

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


具有多个隶属关系下标的作者


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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM