[R] inserting R code in a latex document
Frank E Harrell Jr
f.harrell at vanderbilt.edu
Thu May 12 14:48:54 CEST 2005
I have been trying to use the listings package in LaTeX to do this but
have not been fully happy with the result. Here is what I'm trying:
\lstloadlanguages{R}
\lstset{language=R,basicstyle=\smaller[2],commentstyle=\rmfamily\smaller,
showstringspaces=false,%
xleftmargin=4ex,literate={<-}{{$\leftarrow$}}1 {~}{{$\sim$}}1}
\newcommand{\co}[1]{{\lstinline|#1|}} # for in-line S phrases
\newcommand{\Co}[1]{{\lstinline|#1|}}
\begin{lstlisting}
... S code ...
\end{lstlisting}
If anyone has a better setup please let me know. I'm trying to set
comments in a smaller font and in roman style, and am changing <- to
left arrows and ~ to $\sim$. This also requires the LaTeX relsize package.
Thanks
--
Frank E Harrell Jr Professor and Chair School of Medicine
Department of Biostatistics Vanderbilt University
More information about the R-help
mailing list