1

I am exporting an rmarkdown file to odt, to html, and to pdf. But let's focus on the odt export first.

I want to have an address as part of the YAML header:

---
title: Test Multi
address:
  First Name
  Institute
  Street
  City
output:
  odt_document:
    template: default.opendocument
---

# Just a test document
With some text

This address should then be exported as part of the 'header'. Therefore, I have added the following snippet into the default odt-template (saved as default.opendocument):

$if(address)$
<text:p text:style-name="Author">$address$</text:p>
$endif$

But at the export the line breaks are lost:

enter image description here

Following this answer I tried pipes as in

---
title: Test Multi
address: |
  | First Name
  | Institute
  | Street
  | City
output:
  odt_document:
    template: default.opendocument
---

# Just a test document
With some text

But then, the address is missing completely from the odt.

So, my question is: How can I have the multi-line address from the YAML added to the export preserving the line breaks?

PS: I am using rmarkdown 1.12 and pandoc-2.7.3

Andreas
  • 1,106
  • 9
  • 26

1 Answers1

1

There are two things going on.

  1. As you discovered, you need address: | for YAML to not gobble up your line-breaks.
  2. But the string is treated by pandoc as markdown and pandoc's markdown by default treats linebreaks inside a paragraph as spaces. But you can escape them:
address: |
  First Name \
  Institute \
  Street \
  City
mb21
  • 34,845
  • 8
  • 116
  • 142
  • Thanks for looking into this. Does not fix it for me, though: The address in the exported odt is still missing. – Andreas Aug 19 '19 at 07:39
  • 1
    Ok, I found it. I am not allowed to style this as it will be styled for me and I am ending up with nested `

    `. If I replace `$address$` by `$address$` this works with your syntax in the `Rmd`.

    – Andreas Aug 19 '19 at 07:51