TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I got the help on R functions in .tex format using help_console function. I wonder what is the documentclass and required packages to compile this document correctly. Thanks in advance for your help. My MWE is:




HeaderA{lm}{Fitting Linear Models}{lm}
code{lm} is used to fit linear models.
It can be used to carry out regression,
single stratum analysis of variance and
analysis of covariance (although code{LinkA{aov}{aov}} may provide a more
convenient interface for these).
lm(formula, data, subset, weights, na.action,
   method = qr, model = TRUE, x = FALSE, y = FALSE, qr = TRUE,
   singular.ok = TRUE, contrasts = NULL, offset, ...)



enter image description here

share|improve this question
I think this is done with the sweave tool chain... – Thruston Jan 8 '14 at 11:23
Your code is wrong as all the \commands are lost (the obtained from R really is \HeaderA{lm}{Fitting Linear Models}{lm} \aliasA{print.lm}{lm}{print.lm} etc. – Fran Jan 8 '14 at 12:47
It looks like you lost the first column of the R output and are missing all the \ – David Carlisle Jan 8 '14 at 14:16
@DavidCarlisle: Thanks for your comment. I've checked again and have not lost the first column of the R output. – MYaseen208 Jan 8 '14 at 14:26
well R has then, either way something has dropped the \ (I notice the accepted answer doesn't give any indication of how to preserve the \ other than not removing them.) – David Carlisle Jan 8 '14 at 16:11
up vote 2 down vote accepted

The easy way: Left to R do all the work.


You obtain in this way a PDF really complied with pdflatex with the R help.

The hard way (only useful if you want to modify the source before compiling):

1) Locate Rd.sty (that you should have in your R installation).

In a Linux system:

$ locate Rd.sty

(If you have more than one, as in this case, your mileage may vary. The right here is the second.)

2) Make a simple template document with de Rd package. If LaTeX cannot find the path to Rd.sty, specify the absolute path, or make copy of this file to you working directory.

% paste your R code here

3) Paste the LaTeX chunk obtained with the R help_console function (without lossing the \ characters) in the template:

\HeaderA{lm}{Fitting Linear Models}{lm}
\code{lm} is used to fit linear models.
It can be used to carry out regression,

4) Modify the contents (add, delete, change tex) of this file** as you want and/or a local copy of Rd.sty to have your own style (redefining macros and environments, assuming that you know what are you doing). According to R documentation, the appearance of the output can be also customized through a file ‘Rhelp.cfg’ somewhere in your LaTeX search path, but I have not explored this option.

5) Compile it as usual with pdflatex.

share|improve this answer
(+1): Thanks @Fran for your answer. I need help document in .tex format to use in other documents. Can you explain the 1. Modify this file? – MYaseen208 Jan 8 '14 at 14:59
Got it. Thanks a lot. Much appreciated. – MYaseen208 Jan 8 '14 at 15:10
@MYaseen208 You're welcome. About the step 3 (not 1, sorry): "modify as you want" . Of course, is optional, but I included this point because otherwise would only make sense the faster and easier method of obtain the PDF directly with the help() function. Right? – Fran Jan 8 '14 at 18:16
Thanks @Fran for your help. Do you know any easy way to export the obtained .tex document to LyX? – MYaseen208 Jan 8 '14 at 18:20
@MYaseen208 Have you tried from Lyx menu File > Import > Latex ? But probably many commands will remain as ERT boxes since they are not common LaTeX commands. – Fran Jan 8 '14 at 18:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.