An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-gui/attachments/20080915/30987a79/attachment.pl>
[R-gui] Tinn-R/Latex output
5 messages · David Carslaw, Mike Prager, Frank E Harrell Jr +1 more
4 days later
"David Carslaw" <D.C.Carslaw at its.leeds.ac.uk> wrote:
I find Tinn-R to be an excellent editor for R, but I have one question I have not been able to answer. I wish to include some R code in Latex. Using the Edit/Copy formatted (to export)/TeX does provide Latex-type output. However, there are lots of commands such as \RAIdentifier and \RAOperator etc. that would appear to need either a Latex package to interpret or a list of new commands that describe font attributes etc. My question is whether such a package exists, or is the user expected to define their own commands to interpret them?
David, I also find Tinn-R an excellent editor for R. When I include R code in Latex, I use the Latex "listings" package. It has a wide variety of settings for pretty-printing R code and can be customized by the user. I think that would be more satisfactory in the long run than inserting Latex codes (or having an editor insert Latex codes) to mark R language elements. HTH Mike P.
Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement.
Mike Prager wrote:
"David Carslaw" <D.C.Carslaw at its.leeds.ac.uk> wrote:
I find Tinn-R to be an excellent editor for R, but I have one question I have not been able to answer. I wish to include some R code in Latex. Using the Edit/Copy formatted (to export)/TeX does provide Latex-type output. However, there are lots of commands such as \RAIdentifier and \RAOperator etc. that would appear to need either a Latex package to interpret or a list of new commands that describe font attributes etc. My question is whether such a package exists, or is the user expected to define their own commands to interpret them?
David, I also find Tinn-R an excellent editor for R. When I include R code in Latex, I use the Latex "listings" package. It has a wide variety of settings for pretty-printing R code and can be customized by the user. I think that would be more satisfactory in the long run than inserting Latex codes (or having an editor insert Latex codes) to mark R language elements. HTH Mike P.
The following is how I set up the listings package usage for R. If you
have improvements to this please pass them along. -Frank
\usepackage{listings,relsize}
%Setup for listings package
\lstloadlanguages{R}
\lstset{language=R,basicstyle=\smaller[2],commentstyle=\rmfamily\smaller,
showstringspaces=false,%
xleftmargin=4ex,literate={<-}{{$\leftarrow$}}1 {~}{{$\sim$}}1}
\lstset{escapeinside={(*}{*)}} % for (*\ref{ }*) inside lstlistings (S
code)
Frank E Harrell Jr Professor and Chair School of Medicine
Department of Biostatistics Vanderbilt University
On Fri, Sep 19, 2008 at 4:05 PM, Frank E Harrell Jr
<f.harrell at vanderbilt.edu> wrote:
Mike Prager wrote:
"David Carslaw" <D.C.Carslaw at its.leeds.ac.uk> wrote:
I find Tinn-R to be an excellent editor for R, but I have one question I have not been able to answer. I wish to include some R code in Latex. Using the Edit/Copy formatted (to export)/TeX does provide Latex-type output. However, there are lots of commands such as \RAIdentifier and \RAOperator etc. that would appear to need either a Latex package to interpret or a list of new commands that describe font attributes etc. My question is whether such a package exists, or is the user expected to define their own commands to interpret them?
David, I also find Tinn-R an excellent editor for R. When I include R code in Latex, I use the Latex "listings" package. It has a wide variety of settings for pretty-printing R code and can be customized by the user. I think that would be more satisfactory in the long run than inserting Latex codes (or having an editor insert Latex codes) to mark R language elements. HTH Mike P.
The following is how I set up the listings package usage for R. If you have
improvements to this please pass them along. -Frank
\usepackage{listings,relsize}
%Setup for listings package
\lstloadlanguages{R}
\lstset{language=R,basicstyle=\smaller[2],commentstyle=\rmfamily\smaller,
showstringspaces=false,%
xleftmargin=4ex,literate={<-}{{$\leftarrow$}}1 {~}{{$\sim$}}1}
\lstset{escapeinside={(*}{*)}} % for (*\ref{ }*) inside lstlistings (S
code)
I have played around with:
\definecolor{comment}{rgb}{0.60, 0.60, 0.53}
\definecolor{background}{rgb}{0.97, 0.97, 1.00}
\definecolor{string}{rgb}{0.863, 0.066, 0.266}
\definecolor{number}{rgb}{0.0, 0.6, 0.6}
\definecolor{variable}{rgb}{0.00, 0.52, 0.70}
\lstset{
basicstyle=\ttfamily,
keywordstyle=\bfseries,
identifierstyle=,
commentstyle=\color{comment} \itshape,
stringstyle=, %\color{string}
showstringspaces=false,
columns = fullflexible,
backgroundcolor=\color{background},
mathescape = true,
escapeinside=&&,
fancyvrb
}
Hadley
hadley wickham wrote:
On Fri, Sep 19, 2008 at 4:05 PM, Frank E Harrell Jr <f.harrell at vanderbilt.edu> wrote:
Mike Prager wrote:
"David Carslaw" <D.C.Carslaw at its.leeds.ac.uk> wrote:
I find Tinn-R to be an excellent editor for R, but I have one question I have not been able to answer. I wish to include some R code in Latex. Using the Edit/Copy formatted (to export)/TeX does provide Latex-type output. However, there are lots of commands such as \RAIdentifier and \RAOperator etc. that would appear to need either a Latex package to interpret or a list of new commands that describe font attributes etc. My question is whether such a package exists, or is the user expected to define their own commands to interpret them?
David, I also find Tinn-R an excellent editor for R. When I include R code in Latex, I use the Latex "listings" package. It has a wide variety of settings for pretty-printing R code and can be customized by the user. I think that would be more satisfactory in the long run than inserting Latex codes (or having an editor insert Latex codes) to mark R language elements. HTH Mike P.
The following is how I set up the listings package usage for R. If you have
improvements to this please pass them along. -Frank
\usepackage{listings,relsize}
%Setup for listings package
\lstloadlanguages{R}
\lstset{language=R,basicstyle=\smaller[2],commentstyle=\rmfamily\smaller,
showstringspaces=false,%
xleftmargin=4ex,literate={<-}{{$\leftarrow$}}1 {~}{{$\sim$}}1}
\lstset{escapeinside={(*}{*)}} % for (*\ref{ }*) inside lstlistings (S
code)
I have played around with:
\definecolor{comment}{rgb}{0.60, 0.60, 0.53}
\definecolor{background}{rgb}{0.97, 0.97, 1.00}
\definecolor{string}{rgb}{0.863, 0.066, 0.266}
\definecolor{number}{rgb}{0.0, 0.6, 0.6}
\definecolor{variable}{rgb}{0.00, 0.52, 0.70}
\lstset{
basicstyle=\ttfamily,
keywordstyle=\bfseries,
identifierstyle=,
commentstyle=\color{comment} \itshape,
stringstyle=, %\color{string}
showstringspaces=false,
columns = fullflexible,
backgroundcolor=\color{background},
mathescape = true,
escapeinside=&&,
fancyvrb
}
Hadley
Thanks Hadley. Your specificatins generated a couple of syntax errors for me and typeset the code too large but I'd like to play with it and I'm glad to have it. Frank
Frank E Harrell Jr Professor and Chair School of Medicine
Department of Biostatistics Vanderbilt University