[R] Insert R code in LaTeX document

Anupam Tyagi AnupTyagi at yahoo.com
Sun Sep 17 18:29:04 CEST 2006


Alexandre Depire <depire <at> gmail.com> writes:

> 
> Hello,
> i would like to insert R code in LaTeX document.
> I see something about the 'listings' package, but i would like if it is the
> best way and if it is possible to use the command \include{programme.R}.
> I have the following solution but it doesn't work with \include and \input

Following latex code worked for me. Anupam

\documentclass{report}
\usepackage{listings}
\begin{document}

Somethings .....

\lstset{% general command to set parameter(s)
basicstyle=\small, % print whole in small
stringstyle=\ttfamily, % typewriter type for strings
numbers=left, % numbers on the left
numberstyle=\tiny, % Tiny numbers
stepnumber=2, % number every second line of code
numbersep=5pt, % 5pt seperation between numbering and code listing
language=R }

\lstinputlisting{text1.R}

\end{document}



More information about the R-help mailing list