R语言 为什么相同的从属关系在夸托的pdf输出中重复?

wi3ka0sx  于 2023-04-18  发布在  其他
关注(0)|答案(2)|浏览(117)

夸托文件quarto-file.md重复了相同的附属机构:

---
title: "Hey!"
author:
  - name: Birdy Bird
    affiliations:
      - University of Birds
  - name: None
    affiliations:
      - University of Birds
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>.

我不想重复相同的隶属关系,但是在the answer中使用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$}

如何使相同的从属关系只出现一次(上标相同)?

6kkfgxo0

6kkfgxo01#

您可以使用authors-block扩展名,例如

---
title: "Hey!"
authors:
  - name: Birdy Bird
    affiliations:
      - ref: bird
  - name: None
    affiliations:
      - ref: bird

affiliations:
  - id: bird
    name: University of Birds.
      
filters:
  - authors-block

format: pdf
---

## Quarto

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

rekjcdws

rekjcdws2#

authors-block的使用有一个主要缺陷,它在文档正文中添加了从属关系,而不是在文档序言中(如果你查看底层的tex文件,你可以验证),这会导致作者姓名和从属关系之间有很大的差距,而且如果你使用abstract,从属关系将位于摘要之后,这在视觉上并不好。
因此,我认为,使用title.tex latex-partial来容纳authblk latex包对于正确和良好的从属关系格式应该是更可取的。
现在要注意的关键是,选项affil-id需要是一个数字,将链接作者及其从属关系,它将对应于affiliations键下的id

---
title: "Hey!"
abstract: This is the abstract of the document. And you can see the author affiliations is nicely formatted.
author:
  - name: Birdy Bird
    affil-id: 1
  - name: None
    affil-id: 1

affiliations: 
  - id: 1
    name: University of Birds
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>.

标题.文本

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

要为每个作者添加多个从属关系,请在affil-id键中指定从属关系id编号(逗号分隔)。例如,请参见updated answer here

相关问题