r - Write latex equation inside knitr chunks -
i trying write equation inside chunk. need use '\sum'
r not accept it. got error:
'\s' unrecognized escape in character string
i tried packages without success.
how can bay pass escape character?
here example:
\documentclass{article} \begin{document} <<results='asis',echo=false>>= #library(lazyweave) #library(hwriterplus) #hwritelatex(as.latex("\bar{r}_{i}=\frac{\sum_{t=1}^{t}{r_{i,t}}}{8}")) # cat('\bar{r}_{i}=\frac{\sum_{t=1}^{t}{r_{i,t}}}{8}') #cat("$$","\bar{r}_{i}=\frac{\sum_{t=1}^{t}{r_{i,t}}}{8}","$$",sep="") cat("typically want our paragraphs left justified. expect see when reading.") @ \end{document}
edit. read similar examples no 1 involved escape characters.
you need double escape character.
> cat('\\bar{r}_{i}=\\frac{\\sum_{t=1}^{t}{r_{i,t}}}{8}') \bar{r}_{i}=\frac{\sum_{t=1}^{t}{r_{i,t}}}{8}>
Comments
Post a Comment