[R] in Rd documentation, line breaks in code blocks?

Ulrich Staudinger ustaudinger at gmail.com
Wed Nov 28 21:21:54 CET 2012


Hi everyone,

following the gentle advice from this list, I write a package
description Rd file.

I have a section in there. In this section, I have a subsection. In
this subsection, I want to have a code fragment. This code fragment
should include several commands, spanning several lines.

Example:
==========
\name{aqr-package}
\alias{aqr-package}
\alias{aqr}
\docType{package}
\title{Package level introduction}
\description{description goes here.}

\section{sec1}{

some text.

\subsection{subsec1}{
some text.

\code{
require(aqr)
require(quantmod)
# fetch them via quantmod
getSymbols(c("MSFT", "SAP"))
...
}
}
}
==========

The problem is, everything in \code{} gets printed into one line.
If I add \cr at the end of every line in \code, it gets broken
properly, but a warning says "Tag \cr is invalid in a \code block"

What's the right way to include code (same problem with verbatim) in a
subsection?

Thanks
Ulrich




-- 
Ulrich Staudinger

http://www.activequant.org
Connect online: https://www.xing.com/profile/Ulrich_Staudinger



More information about the R-help mailing list