Message-ID: <428350B6.5080009@vanderbilt.edu>
Date: 2005-05-12T12:48:54Z
From: Frank E Harrell Jr
Subject: inserting R code in a latex document
In-Reply-To: <20050511104620.GB24060@jtkpc.cmp.uea.ac.uk>
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