How to embed/display code in texmaker?

1.6k views Asked by At

I am new to texmaker. I have difficulty in displaying the codes and results I got from R in my texmaker document.

For example I have this results:

> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)

How do I display that in texmaker that it looks like the one you are seeing? (indented, gray background, looks like a code from R).

What do I need to have?

Thanks!

2

There are 2 answers

0
Phil On

Would the listings package (which supports R) achieve what you want?: http://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings

In LaTeX you can also just use the verb(atim) environment for fixed-width, not interpreted text:

/begin{verb}
    > R code goes here...
/end{verb}

?

0
marbles On

If you want to display both the command and the results, then don't you need to execute the R code? (Unless you are planning to copy and paste the results...).

I would suggest checking out the knitr package.