5

In rmarkdown you can create a file _output.yaml which has common options for output formats only (reference)

html_document:
    toc: true
    pandoc_args: ['--base-header-level', 2]
pdf_document:
    toc: true
    pandoc_args: ['--base-header-level', 2]

My question is, is it possible to share non-output options in _output.yaml? Closer to the format used as frontmatter in standard rmarkdown.

e.g.:

bibliography: ../library.bib
author: me
output:
    html_document:
        toc: true
        pandoc_args: ['--base-header-level', 2]
    pdf_document:
        toc: true
        pandoc_args: ['--base-header-level', 2]

such that any document I render in that directory will automatically get author 'me', the specified bibliography path and the output options? (Currently if I do this it complains about an eval call, basically trying to evaluate the value of my first option. "object '..' not found").

It would be handy to avoid replicating some of the non-output-format-specific options in a single file (e.g. author, bibliography).

I know I could work around this by (ab)using pandoc_args, which, being format specific, works when placed into _output.yaml. For example, ["--bibliography", "./library.bib", "--variable", "author:me"] would work in this case, but perhaps not in every case.

This could also be worked around if I could string multiple documents together to be concatenated into a single document; this is what pandoc does. For example pandoc config.yaml chapter1.md chapter2.md works, but render(c('config.yaml', 'chapter1.md', 'chapter2.md')) doesn't.

Aside: is there a way to set a default option for all output formats (e.g. I want to use toc: true for all output formats by default) without having to replicate it?

mathematical.coffee
  • 55,977
  • 11
  • 154
  • 194
  • Interesting question. This one is vaguely related: http://stackoverflow.com/q/23449319/602276 – Andrie Aug 27 '14 at 07:21

0 Answers0