css tex in_header YAML, .
R, .
css
.Courier {
font-family: Courier New, Courier, monospace;
}
- LateX, .
\newenvironment{Courier}{\ttfamily}{\par}
% Trick to avoid pandoc escaping texte between \begin and \end
\newcommand{\nopandoc}[1]{
HTML LateX/PDF:
```{r, echo=FALSE}
beginStyleFmt <- function(textstyle, type = "span") {
outputFormat <- knitr:::pandoc_to()
if (outputFormat %in% c('latex', 'beamer')) {
if (type %in% c("div", "p")) {
paste0("\\nopandoc{\\begin{", textstyle, "}}\n")
} else {
paste0("\\nopandoc{\\", textstyle, "{")
}
} else if (outputFormat == 'html') {
paste0("<", type, " class='", textstyle, "'>")
} else {
""
}
}
endStyleFmt <- function(textstyle, type = "span") {
outputFormat <- knitr:::pandoc_to()
if (outputFormat %in% c('latex', 'beamer')) {
if (type %in% c("div", "p")) {
paste0("\n\\nopandoc{\\end{", textstyle, "}}")
} else {
paste0("}}")
}
} else if (outputFormat == 'html') {
paste0("</", type, ">")
} else {
""
}
}
```
, , # Title, . Courier. , , \\nopandoc{ beginStyleFmt } endStyleFmt.
`r beginStyleFmt("Courier", type = "div")`
```{r comment='', echo=FALSE, results='asis'}
cat(readLines('/filepath/filename.out'), sep = '\n')
```
`r endStyleFmt("Courier", type = "div")`