R语言 为什么在夸托的pdf输出中没有显示附属机构?

w51jfk4q  于 2023-01-10  发布在  其他
关注(0)|答案(2)|浏览(168)

quarto文档的yaml中,我有:

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

当我使用Rstudio IDE呈现这个文件时,我得到:

我期待着与他们的数字(eidogg. 1,2作为上标)的联系会出现在某个地方。

R版本

> 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版本

> 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::quarto_version()
[1] ‘1.2.269’
mzaanser

mzaanser1#

我的猜测是夸托的默认pdf格式不支持作者从属关系,因为在quarto的pdf格式参考中没有这样的提及。
在夸托文档中,Authors & Affiliations讨论了在创建Journal Article Quarto扩展时访问作者和附属关系元数据的方法。
然而,使用下面的LaTeX Partial title.tex可以很好地添加作者的从属关系,它使用乳胶包authblk来进行很好的格式设置和控制格式设置的选项。
(Make确保将 title.texquarto-file.qmd 放在同一目录中)

标题.文本

$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$}

四开文件.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>.

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

在这种情况下,使用以下title.tex胶乳部分,

$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$}

然后如上所述再现quarto-file.qmd文件给出,

浏览authblk文档,了解控制从属关系格式的方法。

eqqqjvef

eqqqjvef2#

我也面临着同样的问题。HTML输出包括作者元数据,但PDF输出不包括。显然,这可以通过包括定义要包括的作者元数据的模板部分来解决这个问题。
在YAML标题中,您需要:

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

在title.tex文件中,您需要类似以下内容:

\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$}

我过去有过这样的工作,但不幸的是它不再工作了(不知道为什么)...
有关模板部分的更多信息可以在这里获得:夸托模板部分
模板可以在GitHub链接中找到:Quarto GitHub PDF Templates

相关问题