RMarkdown 的 YAML 中的作者和附属机构 [英] Authors and affiliations in the YAML of RMarkdown

查看:13
本文介绍了RMarkdown 的 YAML 中的作者和附属机构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题过去已经在这个论坛中提出过 (

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

HTML 输出

我看到的是作者,而不是所有的单位编号.隶属关系本身仍然隐藏.

DOCX 输出

最终的 Word 文件中既不会出现姓名也不会出现从属关系.

我的系统

我正在使用最新的 RStudio 版本(版本 1.1.453),在 Linux Mint 19 Cinnamon 上运行.

更新:原始示例

---标题:我的标题"作者:- 马里奥·莫德斯托-马塔:电子邮件:palomariomm@gmail.com研究所:[cenieh, ucl1, ppex]对应:真实- M.克里斯托弗·迪恩:研究所:[ucl2, nhm]- 尤丽叶特·昆蒂诺:机构:乌布- 丽贝卡·加西亚-冈萨雷斯:机构:乌布- 罗德里戈·S·拉克鲁斯:机构:纽- Timothy G. Bromage:机构:纽- 塞西莉亚·加西亚-坎波斯:研究所:[cenieh,ucl1]- Marina Martínez de Pinillos:研究所:cenieh- 劳拉·马丁-弗朗西斯:研究所:[bor,cenieh]- 玛丽亚·马蒂农-托雷斯:研究所:[cenieh,ucl1]- 尤达·卡博内尔:研究所:[iphes, urv]- 胡安·路易斯·阿苏加:研究所:[isciii,ucm]- 何塞·玛丽亚·贝穆德斯·德卡斯特罗:研究所:[cenieh,ucl1]研究所:- cenieh: Centro Nacional de Investigación sobre la Evolución Humana (CENIEH), Paseo Sierra de Atapuerca 3, 09002, Burgos, Spain- ucl1:伦敦大学学院人类学系,伦敦,WC1H 0BW,英国- ucl2:伦敦大学学院细胞与发育生物学系,高尔街,伦敦,WC1E 6BT,英国- ubu: Laboratorio de Evolución Humana, Unierisdad de Burgos, Edificio I+D+i, Burgos, 西班牙- ppex: Equipo Primeros Pobladores de Extremadura, Casa de Cultura Rodríguez Moñino, 卡塞雷斯, 西班牙- nhm:人类进化研究中心 (CHER),地球科学系,自然历史博物馆,伦敦,SW7 5BD,英国- 纽约大学:纽约大学- 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,马德里,西班牙- ucm: Departamento de Geodinámica, Estratigrafía y Paleontología, Facultad de Ciencias Geológicas, Universidad Complutense de Madrid, 西班牙日期:2018 年 10 月 1 日"输出:pdf_文档:number_sections: 是目录:是的目录深度:4pandoc_args:- '--lua-filter=scholarly-metadata.lua'- '--lua-filter=author-info-blocks.lua'html_文档:css:脚本 accesorios/estiloboton.cssnumber_sections: 是题材:砂岩目录:是的目录深度:4word_document:目录:是的pandoc_args:- '--lua-filter=scholarly-metadata.lua'- '--lua-filter=author-info-blocks.lua'参考书目:references.bibcsl:科学.csl---

解决方案

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

如果目标只是 PDF,我建议由 RStudio 提供

虽然这是 Word 中的样子:

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

I know this question was already asked in the past in this forum (1, 2, 3). Before you mark this as duplicated, I tried all the answers with no success. Most of the questions were asked long ago, and some updates related with pandoc might affect nowadays results.

The issue is that I am writing a scientific paper using RMarkdown, and would like to export the results either in HTML, PDF or Word files.

More importantly is that there are 12 authors signing the papers. Some of the authors present more than one affiliation, and some authors presenting the same affiliation.

My question is very clear: How can I edit the YAML to include all the authors with all the affiliations in the YAML in order to export to different formats (HTML, PDF, DOC)?

I tried this 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 output

This is what I see when I export to PDF the .Rmd file:

Instead of the authors, I see true and no affiliations.

HTML output

I see the authors and not all the affiliation numbers. The affiliations themselves remain hidden.

DOCX output

Neither names nor affiliations appear in the final Word file.

My system

I am using the latest RStudio version (Version 1.1.453), running on Linux Mint 19 Cinnamon.

UPDATE: original example

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

解决方案

There is, to the best of my knowledge, no one-size-fits-it-all solution as of now.

If the target was only PDF, I'd suggest rticles by RStudio. It's great.

A solution which also works with docx is more difficult. One possibility is to use pandoc Lua filters. The repository collecting useful filters contains two filters which will help you: scholarly-metadata and author-info-blocks. (Disclosure: I wrote these.)

Place the .lua files in your directory, change the YAML structure a bit, and instruct pandoc to run the filters:

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

This will be the PDF output:

while this is what it looks like in Word:

The affiliation and contact information is added to the body text, which is why the toc is displayed above it.

这篇关于RMarkdown 的 YAML 中的作者和附属机构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆