How to save the original empty space in a string when writing Rd documentation?

In connection with the attempt to find a solution for myself regarding this issue , I was immersed in an attempt to write a valid Rd markup. I want to add a section with a name Raw Function Codeand put the function code in it. I have achieved limited success in this regard by writing a script to modify Rd files to include

\section{Raw Function Code}{\code{
# some piece of R script will eventally provide this part of the text
}}

However, even if I manually placed the text in the .Rd file correctly (using spaces or tabs), the initial empty space of each line seems to be deleted, leaving an unwanted search function. I noticed that if I provide the leading character before the space, the space is saved. However, I did not want to provide a start character, because I would like people to be able to copy and paste directly from the generated PDF file.

I looked at parseRd and I know that there are three types of LaTeX text - for example, R-like and verbatim. I tried to put my function code in \ code and in \ verb, and none of them gave the desired results. What can I do to keep the original empty space?

+5
source share
3 answers

\section LaTeX, , \synopsis, ..

\synopsis
# some piece of R script will eventally provide this part of the text
} 

, ; , . \examples, - , , , ( , , , "" ).

+1

Rd. . Hemmo . , , , .

( Wiki . R-2.15.1)

+1

If you need a super hacker way to do this, you can use \Sexprto create zero-width characters and add spaces between them:

#' first line \cr
#'\Sexpr{"\u200B"} \Sexpr{"\u200B"} \Sexpr{"\u200B"} \Sexpr{"\u200B"} indented line

A warning though - your package will build fine, but R CMD CHECK will throw the appropriate one.

0
source

All Articles