2

In the .Rmd below I have includes: in_header: for pdf output and includes: before_body: for docx output. Is there something analogous for docx output?

My current hack is to include the <!--- For DOCX Only ---> code chunk conditionally when producing docx output. But I'd prefer not to have this clutter up the body of my .Rmd and move it out into some sort of preamble-word.tex file.

tinytextest.Rmd

---
title: "TinyTeX Test"
author: "Me"
date: "5/3/2019"
output:
  word_document: default
  html_document:
    includes:
      before_body: preamble-mathjax.tex
  pdf_document:
    includes:
      in_header: preamble-v02.tex
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

<!--- For DOCX Only --->
`r if (!knitr:::is_latex_output() & !knitr:::is_html_output()) '
\\newcommand{\\mathbbm}[1]{\\mathbf{#1}}
'`

Hello

\[\mathbbm{1}_{S}(x)\]

preamble-mathjax.tex

\(\\newcommand{\\mathbbm}[1]{\\mathbf{#1}}\)

preamble.tex

\usepackage{bbm}
lowndrul
  • 3,715
  • 7
  • 36
  • 54

0 Answers0