markdown - 将 Rmd 中的目录和从属关系列表分离为 PDF 文件
问题描述
最近有人批评我在从 R Markdown 文件创建 PDF 时没有明确区分 TOC 和 Affiliation 列表。
我的 YAML 就是这个
---
title: "title"
author:
- Name author 1:
email: paleomariomm@gmail.com
institute: [cenieh, ucl1, ppex]
correspondence: true
- Name author 2:
institute: [ubu]
institute:
- cenieh: Centro Nacional de Investigación sobre la Evolución Humana (CENIEH), Paseo Sierra de Atapuerca 3, 09002, Burgos, Spain
- ucl1: Department of Anthropology, University College London, London, WC1H 0BW, UK
- ppex: Equipo Primeros Pobladores de Extremadura, Casa de Cultura Rodríguez Moñino, Cáceres, Spain
- ubu: Laboratorio de Evolución Humana, Universidad de Burgos, Edificio I+D+i, Burgos, Spain
output:
pdf_document:
number_sections: yes
pandoc_args:
- '--lua-filter=lua/scholarly-metadata.lua'
- '--lua-filter=lua/author-info-blocks.lua'
toc: yes
toc_depth: 4
---
通过将此 Rmd 文件转换为 PDF,我看到:
如您所见,TOC 和从属关系列表之间可能会出现一些潜在的误解,因为从属关系列表就在目录的下方。
我想清楚地分开它们。我想到了不同的可能性:
- 引入一条分隔两个部分的线。
- 在隶属关系列表顶部添加一个小标题,说明Affiliation。
- 颠倒顺序并将隶属关系列表放在作者下方。
我一直在解决这些情况,但没有成功。关于如何实施其中任何一个的任何想法?
解决方案
隶属关系列表作为主体的一部分添加。Pandoc 将目录作为正文的第一项插入,这就是从属关系出现在 TOC 之后的原因。最好的解决方法是禁用自动 TOC 插入,并手动调用 LaTeX 命令。
output:
pdf_document:
number_sections: yes
pandoc_args:
- '--lua-filter=lua/scholarly-metadata.lua'
- '--lua-filter=lua/author-info-blocks.lua'
toc: no
然后加
```{=latex}
\setcounter{tocdepth}{4}
\tableofcontents
```
在文档的顶部。Lua 过滤器会将 affiliations 部分推到顶部,在目录上方,pandoc 不会更改顺序。
推荐阅读
- r - str_c 在 R 中使用 "
- createfile - CreateFile 以 5 失败
- android - 应用程序模块也可以用作库模块吗?
- c# - 使用 Entity Framework Core 将数据存储和检索为 JSON 字符串?
- amazon-web-services - AWS CDK:将数据库实例分配给集群
- google-apps-script - 直接从 Sheets 将脚本部署为 Webapp
- swift - 将字符串转换为货币数字格式,带、不带或带 0 个小数位
- sql - 根据唯一条件在 HIVE 中创建新表选择记录
- python - 如何过滤给定时间范围的数据框?
- php - Symfony 5 登录表单操作返回无效的 CSRF 令牌