Christian Olesen
Christian Olesen

Reputation: 69

Writing greek letters in rmarkdown to docx (newcommand for docx)

I am trying to write none-italic "uL" (microliters) in R markdown with the letter "mu". It is no problem creating a newcommand for PDF that replaces "\microliters" with "uL".

newcommand{\microliters}{\textmu L}

This (of course?) does not work when knitting to docx. As a workaround, I can live with \microliters being replaced by a "uL" with a regular "u" - in stead of "mu".

But how can I create a docx "newcommand", that does that?

Upvotes: 0

Views: 881

Answers (2)

avrincon
avrincon

Reputation: 11

I'm not sure about "newcommand", but this works when converting from rmarkdown to docx:

µl

or

μ

Upvotes: 1

Christian Olesen
Christian Olesen

Reputation: 69

I finally got a solution - not sure if any of the packages are mandatory, so I have included them all:

---
title: "Concentrationmeasurements"
author: "Christian Aa. Olesen"
date: "April 29, 2018"
output:
  word_document: default
  pdf_document:
    latex_engine: pdflatex
header-includes:
- \usepackage{float}
- \floatplacement{figure}{H}
- \usepackage{setspace}
- \doublespacing
- \usepackage{lipsum}
- \usepackage{multirow}
- \usepackage[table,xcdraw]{xcolor}
- \usepackage{lineno}
- \linenumbers
- \usepackage{rotating}
- \usepackage{tikz}
- \usepackage{enumitem}
- \usepackage{blindtext}
- \usepackage{textcomp}
- \usepackage{refstyle}
- \usepackage{graphicx}
- \usepackage[font=small,labelfont=bf]{caption}
- \usepackage{tabularx}
- \usepackage[page]{appendix}
- \usepackage{amsmath}
- \usepackage{amsfonts}
- \usepackage{amssymb}
- \usepackage{hyperref}
- \usepackage{textcomp}
- \usepackage{graphicx}
- \usepackage{amsmath}
- \usepackage{xspace}
- \newcommand{\rtmark}{\textsuperscript{\textregistered}\xspace}
- \usepackage{multirow}
- \usepackage{float}
---
```{r,echo=FALSE, results='asis'}
doc.type <- knitr::opts_knit$get('rmarkdown.pandoc.to')

if (doc.type == "docx") cat(paste("\\newcommand{\\microliters}{\\mathrm{\\mu l}}")) else cat(paste("\\newcommand{\\microliters}{\\textrm{\\textmu l}}","\n"))

```

Upvotes: 0

Related Questions