Authors and affiliations in the YAML of RMarkdown

前端 未结 1 1044
余生分开走
余生分开走 2020-12-16 16:55

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 question

相关标签:
1条回答
  • 2020-12-16 17:20

    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.

    0 讨论(0)
提交回复
热议问题