I am creating pdf files from R markup files (.Rmd). I would like to create an output with the LaTeX listing package. Is there a way to tell the .Rmd file which style to wrap the output of R in?
For example, the following Rmd:
```{R}
1:10
````
running through knitr and pandoc produces:
\begin{lstlisting}[language=R]
1:10
\end{lstlisting}
\begin{lstlisting}
[1] 1 2 3 4 5 6 7 8 9 10
\end{lstlisting}
I did not find a way to distinguish two listings in a pdf file. It seems to me that I need either a style on one, or both lstlistings, or give an output a language parameter that I could add to the header. For example, this will work:
\begin{lstlisting}[language=R,style=Rsource]
1:10
\end{lstlisting}
\begin{lstlisting}
[1] 1 2 3 4 5 6 7 8 9 10
\end{lstlisting}
Since I could add something to the header so that the Rsource style is different from the default lists:
\lstset{language=R,frame=single}
\lstdefinestyle{Rsource}{
backgroundcolor=\color[gray]{0.95},
}
Both the code and the output are displayed here, but only the code is shaded. Is there a way to specify this from an Rmd source? I do not want to manually change tex output.
, pandoc -highlighting-style . , , , . , ( ), , pandoc.
, pandoc sed, , . tex.stackexchange. , knitr / pandoc.