Re: [R] inserting R code in a latex document

From: Frank E Harrell Jr <f.harrell_at_vanderbilt.edu>
Date: Thu 12 May 2005 - 22:48:54 EST

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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Thu May 12 22:55:51 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:44 EST