Created
May 24, 2017 03:31
-
-
Save dantonnoriega/eab3851ab60e1f35fb17afbf3c0a4cd4 to your computer and use it in GitHub Desktop.
how to get a percent sign when spinning with latex or html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: TEST | |
output: | |
pdf_document: | |
latex_engine: xelatex | |
html_document: | |
fig_caption: true | |
--- | |
```{r, echo = FALSE} | |
knitr::opts_chunk$set( | |
collapse = TRUE, | |
echo = TRUE, | |
cache = FALSE, | |
comment = "#>", | |
fig.path = "fig-", | |
fig.pos = "h" | |
) | |
# this will check what the output format is going to be | |
getOutputFormat <- function() { | |
knitr::opts_knit$get("rmarkdown.pandoc.to") | |
} | |
``` | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. | |
```{r, warning=FALSE, message=FALSE, echo=FALSE, eval=TRUE, results='asis'} | |
s <- "$$\\text{\\% change} = \\frac{x_2 - x_1}{x_1} \\times 100$$" | |
if(getOutputFormat() == 'html') s <- gsub('\\\\%', '%', s) # dont escape if html | |
knitr::asis_output(s) | |
``` | |
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment