[R] including r code in a latex file

Prof Brian D Ripley ripley at stats.ox.ac.uk
Mon May 1 23:33:36 CEST 2000


On Mon, 1 May 2000, Faheem Mitha wrote:

> Dear R people,
> 
> The header practically says it all. I was wanting to include r code in a
> Latex file. Since R code using{ and }, which are interpreted by Latex as
> control characters, I would expect it to get upset.
> 
> I believe that \{ would probably print as {, but I hoping I don't have to
> go through the code and add lots of \. I would rather use some global
> commannd, along the lines of \treatastext{R code}.
> 
> Is there something like this? I'm not that familiar with Latex.

Use a verbatim environment (or \verb for inline text).  Lots of other
things like ^ and ~ will cause problems in LaTeX too.  Alternatively,
look hard at how the Rdconv does it using Rd.sty.  (V&R has a custom-made
verbatim-like environment with a custom virtual tt font, for example.)

Alternatively, investigate one of the many program-setting packages you can
find on CTAN, or the S.sty on statlib (used for the White Book).

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list