2009/1/28 Peter Dunn <pdu...@usc.edu.au>:
> Hi all
>
> I use Sweave extensively to mix R and LaTeX, and often have R code appearing 
> in my LaTeX document.
>
> Just a quick question then: What is the best way to add example of R commands 
> into LaTeX in-line?  (That is, not using Sweave.)  For example, suppose I 
> wish to place in my document this instruction:
> [...] *snip*

Try this:

\usepackage{listings}

\lstset{%
        basicstyle=\scriptsize,
        breaklines=true,
        frame=single,
        literate=
                {<-}{$\leftarrow$}{2}
}

\renewcommand\lstlistlistingname{List of listings}


Have a look at the listings package... You can see I'm making the font
size smaller, giving all code a frame, and converting <- into a proper
left arrow (just for R!)

listings is very capable.

http://www.ctan.org/tex-archive/macros/latex/contrib/listings/
http://www.ctan.org/get/macros/latex/contrib/listings/listings.pdf

bw

Mark
-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to