From ripley at stats.ox.ac.uk  Wed Mar 10 12:31:23 2004
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Wed Mar 10 12:31:29 2004
Subject: [Rd] Rd - \preformatted, \section and LaTeX problem
In-Reply-To: <003301c40690$044fea60$e502eb82@maths.lth.se>
Message-ID: <Pine.LNX.4.44.0403101123480.17476-100000@gannet.stats>

I believe this is already corrected in 1.9.0 alpha, but your example is 
actually invalid (it has unbalanced braces).

This syntactically correct example works in 1.9.0 alpha, but not in 1.8.1.

\name{Example}
\alias{Example}
\keyword{documentation}
\title{Example}
\description{
  Example
\preformatted{
  No problems here!
}
}
\section{A section}{
  \preformatted{
    \end{verbatim}\end{Section}
  }
}


On Wed, 10 Mar 2004, Henrik Bengtsson wrote:

> Hi, 
> 
> I have found an unwanted feature in the Rd to LaTeX convertion
> regarding \preformatted inside a \section. I have created an Rd
> example below, which generates an error in the following 'R CMD check'
> step
> 
>  * creating aroma.affine-manual.tex ... OK
>  * checking aroma.affine-manual.tex ... ERROR
>  LaTeX errors when creating DVI version.
>  This typically indicates Rd problems.
> 
> I believe the Rd code itself explains the details, the reasons, and
> the work around. Should it be reported as a bug?

Only if you have tested it on the current alpha.

> Best wishes
> 
> Henrik Bengtsson
> 
> running Rv1.8.1 and MikTeX v2.4 on WinXP with B.R.'s Rtools.
> 
> 
> -------------------------------------------------------
> Begin Rd example
> -------------------------------------------------------
> \name{Example}
> \alias{Example}
> \keyword{documentation}
> 
> \title{Example}
> 
> \description{
>   Example
> \preformatted{
> No problems here!
> }
> }
> 
> \section{A section}{
> If an 'preformatted' Rd environment (or whatever it's called) 
> within a 'section' is not followed by a newline before the end
> of the 'section' the LaTeX version of it generated by \code{R CMD
> check}
> will end like:
> \preformatted{
>   \end{verbatim}\end{Section} 
> }
> and the LaTeX compiler will complain saying:
> \preformatted{
> ! LaTeX Error: \begin{list} on input line 49 ended by \end{document}.
> See the LaTeX manual or LaTeX Companion for explanation.
> Type  H <return>  for immediate help.
>  ...
> l.59 \end{document}
> ?
> }
> For LaTeX to work, there has to be a newline between like this:
> \preformatted{
>   \end{verbatim}
>   \end{Section} 
> }
> The problem is that empty lines are stripped (for 'section's only?!?).
> 
> A work around seems to add a non-empty line. Try for instance to add
> the
> following after this 'preformatted' Rd environment at it will
> work (as it is now, it will not work!):
> \preformatted{
> \emph{} % A dummy line to "fool" R CMD check and LaTeX
> }
> }
> -------------------------------------------------------
> End Rd example
> 
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
> 
> 

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


[Rd] Rd - \preformatted, \section and LaTeX problem
Prof Brian Ripley