我知道过去在这个论坛(
1,
2,
3)已经提出了这个问题.在将此标记为重复之前,我尝试了所有答案但没有成功.大多数问题很久以前就被提出过了,与pandoc相关的一些更新可能会影响现在的结果.
问题是我正在使用RMarkdown撰写科学论文,并希望以HTML,PDF或Word文件的形式导出结果.
更重要的是,有12位作者签署了这些文件.一些作者提出了多个联盟,一些作者提出了相同的联系.
我的问题非常明确:我如何编辑YAML以包含YAML中所有隶属关系的所有作者,以便导出为不同的格式(HTML,PDF,DOC)?
我试过这个YAML:
---
title: "My title"
author:
- name: Mario Modesto-Mata^1,2^
email: paleomariomm@gmail.com
- name: Christopher^1^
- name: Seaghán Mhartain^2^
- name: Rita Yuri Ynoue^1^
address:
- code: 1
address: Instituto de Astronomía, Geofísica e Ciências Atmosféricas, Universidade de São Paulo
- code: 2
address: Faculdade de Medicina, Universidade de São Paulo
date: "1 October 2018"
output:
pdf_document:
number_sections: yes
toc: yes
toc_depth: 4
word_document:
toc: yes
html_document:
css: Scripts accesorios/estiloboton.css
number_sections: yes
theme: sandstone
toc: yes
toc_depth: 4
bibliography: references.bib
csl: science.csl
---
PDF输出
这是我在导出到PDF .Rmd文件时看到的内容:
而不是作者,我认为是真实的,没有隶属关系.
HTML输出
我看到作者而不是所有的联盟号码.从属关系本身仍然隐藏着.
DOCX输出
最终的Word文件中不会显示任何名称或附属关系.
我的系统
我正在使用最新的RStudio版本(版本1.1.453),在Linux Mint 19 Cinnamon上运行.
更新:原始示例
---
title: "My title"
author:
- Mario Modesto-Mata:
email: paleomariomm@gmail.com
institute: [cenieh, ucl1, ppex]
correspondence: true
- M. Christopher Dean:
institute: [ucl2, nhm]
- Yuliet Quintino:
institute: ubu
- Rebeca García-González:
institute: ubu
- Rodrigo S. Lacruz:
institute: nyu
- Timothy G. Bromage:
institute: nyu
- Cecilia García-Campos:
institute: [cenieh, ucl1]
- Marina Martínez de Pinillos:
institute: cenieh
- Laura Martín-Francés:
institute: [bor, cenieh]
- María Martinón-Torres:
institute: [cenieh, ucl1]
- Eudald Carbonell:
institute: [iphes, urv]
- Juan Luis Arsuaga:
institute: [isciii, ucm]
- José María Bermúdez de Castro:
institute: [cenieh, ucl1]
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
- ucl2: Department of Cell and Developmental Biology, University College London, Gower Street, London, WC1E 6BT, UK
- ubu: Laboratorio de Evolución Humana, Unierisdad de Burgos, Edificio I+D+i, Burgos, Spain
- ppex: Equipo Primeros Pobladores de Extremadura, Casa de Cultura Rodríguez Moñino, Cáceres, Spain
- nhm: Centre for Human Evolution Research (CHER), Department of Earth Sciences, Natural History Museum, London, SW7 5BD, UK
- nyu: New York University
- bor: De la Préhistoire à l'Actuel - Culture, Environnement et Anthropologie, University of Bordeaux, CNRS, MCC, PACE, UMR 5199 F_33615, Pessac Cedex, France
- iphes: Institut Català de Paleoecologia Humana i Evolució Social (IPHES), Zona Educacional 4, Campus Sescelades, Edifici W3, Universitat Rovira i Virgili, Tarragona, Spain
- urv: Àrea de Prehistòria, Universitat Rovira i Virgili, Avinguda de Catalunya 35, 43002, Tarragona, Spain
- isciii: Centro mixto UCM-ISCIII de Evolución y Comportamiento humanos, Madrid, Spain
- ucm: Departamento de Geodinámica, Estratigrafía y Paleontología, Facultad de Ciencias Geológicas, Universidad Complutense de Madrid, Spain
date: "1 October 2018"
output:
pdf_document:
number_sections: yes
toc: yes
toc_depth: 4
pandoc_args:
- '--lua-filter=scholarly-metadata.lua'
- '--lua-filter=author-info-blocks.lua'
html_document:
css: Scripts accesorios/estiloboton.css
number_sections: yes
theme: sandstone
toc: yes
toc_depth: 4
word_document:
toc: yes
pandoc_args:
- '--lua-filter=scholarly-metadata.lua'
- '--lua-filter=author-info-blocks.lua'
bibliography: references.bib
csl: science.csl
---
最佳答案 据我所知,目前还没有一个适合所有人的解决方案.
如果目标只是PDF,我建议使用RStudio的rticles.这很棒.
与docx一起使用的解决方案更加困难.一种可能性是使用pandoc Lua filters. repository collecting useful filters包含两个过滤器,可以帮助您:scholarly-metadata和author-info-blocks.(重要免责声明:我写了这些.)
将.lua文件放在目录中,稍微更改YAML结构,并指示pandoc运行过滤器:
---
title: "My title"
author:
- Mario Modesto-Mata:
email: paleomariomm@gmail.com
institute: [astro, med]
correspondence: true
- name: Christopher
institute: astro
- name: Seaghán Mhartain
institute: med
- name: Rita Yuri Ynoue
institute: astro
institute:
- astro: Instituto de Astronomía, Geofísica e Ciências Atmosféricas, Universidade de São Paulo
- med: Faculdade de Medicina, Universidade de São Paulo
date: "1 October 2018"
output:
word_document:
toc: yes
pandoc_args:
- '--lua-filter=scholarly-metadata.lua'
- '--lua-filter=author-info-blocks.lua'
pdf_document:
number_sections: yes
toc: yes
toc_depth: 4
pandoc_args:
- '--lua-filter=scholarly-metadata.lua'
- '--lua-filter=author-info-blocks.lua'
---
这将是PDF输出:
虽然这是Word中的样子:
联系和联系信息被添加到正文中,这就是toc显示在正文上方的原因.