【问题标题】:Authors and affiliations in the YAML of RMarkdownRMarkdown 的 YAML 中的作者和附属机构
【发布时间】:2018-10-21 18:49:19
【问题描述】:

我知道这个问题过去已经在这个论坛中提出过(123)。在将其标记为重复之前,我尝试了所有答案,但均未成功。大多数问题都是很久以前提出的,与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 输出

这是我将.Rmd 文件导出为 PDF 时看到的内容:

我看到的不是作者,而是true 并且没有隶属关系。

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

【问题讨论】:

  • 您好,您找到替代解决方案了吗?

标签: yaml markdown r-markdown pandoc


【解决方案1】:

据我所知,目前还没有万能的解决方案。

如果目标只是 PDF,我建议 RStudio 提供rticles。太好了。

同样适用于 docx 的解决方案更加困难。一种可能性是使用 pandoc Lua filtersrepository collecting useful filters 包含两个可以帮助您的过滤器:scholarly-metadataauthor-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 中的样子:

从属机构和联系信息添加到正文中,这就是目录显示在其上方的原因。

【讨论】:

  • 我下载了两个过滤器.lua 并放在我的目录文件夹中。但是,它给出了一个错误提示 unrecognized optionError: pandoc document conversion failed with error 2.
  • 似乎是旧的 pandoc 版本。你能更新 RStudio 吗?
  • 这是我最后一个版本的 RStudio。有没有办法单独更新pandoc?
  • 有趣。它似乎适用于所示示例,但不适用于真实示例。我更新了包括原始问题在内的问题。真人可能有什么问题?错误和之前的两个cmet一样...
  • 如果您有其他问题、愿望或功能请求,请随时在 GitHub 上open an issue
猜你喜欢
  • 2014-11-20
  • 2020-02-14
  • 1970-01-01
  • 1970-01-01
  • 2014-10-12
  • 1970-01-01
  • 2021-06-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多