Dirk Eddelbuettel
2008-Apr-06 15:40 UTC
[R] [OT] Typesetting / highlighting R code in Latex
Using Latex and the beamer class, I would like to highlight code snippets. Does anybody know a suitable 'preprocessor' or 'filter' for R (and/or C/C++) code ? I have been including it in simple \begin{verbatim} ... \end{verbatim} and I know there is a better way -- in fact I saw it used a while back in some package I looked at. And I didn't write that down... What I am looking for is the basic equivalent of 'everything in verbatim' plus the ability to hightlight certain parts to stress the points I'd like to make. There must be something. Pointers would be greatly appreciated! Thanks, Dirk -- Three out of two people have difficulties with fractions.
On 06/04/2008 11:40 AM, Dirk Eddelbuettel wrote:> Using Latex and the beamer class, I would like to highlight code snippets. > Does anybody know a suitable 'preprocessor' or 'filter' for R (and/or C/C++) > code ? > > I have been including it in simple \begin{verbatim} ... \end{verbatim} and I > know there is a better way -- in fact I saw it used a while back in some > package I looked at. And I didn't write that down... > > What I am looking for is the basic equivalent of 'everything in verbatim' > plus the ability to hightlight certain parts to stress the points I'd like to > make. > > There must be something. Pointers would be greatly appreciated!Sweave uses the fancyvrb package, which allows quite a lot of customization. I don't think it would be easy to use Sweave to apply different highlighting to different parts of R code, but you could use fancyvrb directly. When combining Sweave and beamer, you need to remember the opening \begin{frame}[containsverbatim] but that's probably true for \begin{verbatim} too. I've also used the listings package (not with beamer), but didn't stick with it, I think because I didn't like the default style and was too lazy to customize it. Duncan Murdoch
Dirk Eddelbuettel
2008-Apr-06 18:44 UTC
[R] [OT] Typesetting / highlighting R code in Latex
On 6 April 2008 at 10:40, Dirk Eddelbuettel wrote: | Using Latex and the beamer class, I would like to highlight code snippets. | Does anybody know a suitable 'preprocessor' or 'filter' for R (and/or C/C++) | code ? | | I have been including it in simple \begin{verbatim} ... \end{verbatim} and I | know there is a better way -- in fact I saw it used a while back in some | package I looked at. And I didn't write that down... | | What I am looking for is the basic equivalent of 'everything in verbatim' | plus the ability to hightlight certain parts to stress the points I'd like to | make. | | There must be something. Pointers would be greatly appreciated! The listing class was what I was looking for -- thanks for the quick off-list reply. Basic synopis of listing is eg here http://en.wikibooks.org/wiki/LaTeX/Packages/Listings Dirk -- Three out of two people have difficulties with fractions.