noamross / redoc

[NOTE: Project in suspended animation for now] Reversible Reproducible Documents
https://noamross.github.io/redoc
Other
514 stars 44 forks source link

redoc not rendering using the reference document styles #51

Closed mattwarkentin closed 5 years ago

mattwarkentin commented 5 years ago

Hi Noam,

I asked you on Twitter about how to use a reference DOCX file to change the formatting of a redoc document. I figured it was the same providing a reference_docx to a standard R Markdown with output as word_document; and you confirmed this to be the case and asked that I file an issue if it didn't work.

Here is the basics of what I did:

- Open RStudio
- File >> New File >> R Markdown... >> From Template >> redoc

With the following YAML header:

---
title: Reversible R Markdown Document
subtitle: Your subtitle
author: Your Name
date: Created `r Sys.Date()`
output:
  redoc::redoc:
    reference_docx: /path/to/file/ref-style-serif.docx
---

I have attached the reference file here (ref-style-serif.docx), if that helps. In the same session, I verified that I can pass the reference doc to a standard word_document format R Markdown file and it does indeed render using the reference format. So it seems like something specific to redoc. The reference document I am providing was created using the recommended approach (i.e. get a template word document from pandoc and modify the style as preferred.

Session Info ```r R version 3.5.3 (2019-03-11) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS Mojave 10.14.4 ``` Pandoc version (get with rmarkdown::pandoc_version): > rmarkdown::pandoc_version() [1] ‘2.7.2’ RStudio version (if applicable): Version 1.2.1335
noamross commented 5 years ago

This works for me, in that I get an output document with Garamond font. Is this not the case for you?

noamross commented 5 years ago

If not, do attach the output file that you generate, as well.

mattwarkentin commented 5 years ago

@noamross Hmm, very peculiar that it is working for you...

I ran the same setup as before:

---
title: Reversible R Markdown Document
subtitle: Your subtitle
author: Your Name
date: Created `r Sys.Date()`
output:
  redoc::redoc:
    reference_docx: /Users/Matt/Documents/pandoc-ref-styles/ref-style-serif.docx
---

I tried again and had no luck. Here is the output file: redoc.docx

It does not have the correct font, margins, headers, etc.

No errors in RStudio R Markdown pane, however, it doesn't look like the template is being passed to pandoc, right?

/usr/local/bin/pandoc +RTS -K512m -RTS redoc.utf8.md --to docx+empty_paragraphs --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart+fenced_divs+bracketed_spans --output redoc.docx --highlight-style tango --lua-filter /Library/Frameworks/R.framework/Versions/3.5/Resources/library/redoc/lua-filters/protect-empty.lua
noamross commented 5 years ago

According to the diagnostics in your redoc.docx, you're using an old commit of redoc (0ee885e). Can you re-install the latest version try again?

mattwarkentin commented 5 years ago

@noamross Good suggestion! I had to update diffobj first and then re-installed redoc and everything now seems to be working as expected. Thanks for your help.