From ripley at stats.ox.ac.uk  Tue Dec  9 22:42:42 2003
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Tue Dec  9 22:41:28 2003
Subject: [Rd] latex problem with \preformatted (PR#5645)
In-Reply-To: <20031209213448.A4EE5F4DB@slim.kubism.ku.dk>
Message-ID: <Pine.LNX.4.44.0312092141250.30404-100000@gannet.stats>

Have you tried the *current* version of R?

>From NEWS

   o   Rd conversion to latex did not add a new line before
       \end{Section} for the section environments, which caused
       problems if the last thing in a section was \preformatted{}
       (and potentially elsewhere).


On Tue, 9 Dec 2003 gregory_r_warnes@groton.pfizer.com wrote:

> This message is in MIME format. Since your mail reader does not understand
> this format, some or all of this message may not be legible.
> 
> ------_=_NextPart_000_01C3BE9C.3FB5BC1A
> Content-Type: text/plain; charset="iso-8859-1"
> 
> 
> There is a small bug in the implementation of \preformatted in R 1.8.0:
> The closing "\end{verbatim}" needs to be followed by a newline, since my
> latex ignores everything following it on the line.
> 
> 
> In an .Rd file I have:
> 
> 
> \details{
>   This function provides a thin wrapper around the Unix "fork" system
>   call, which will create a new process which is an exact copy of the
>   [...]
>     
> \preformatted{
>   {
>     pid = fork(slave=NULL) 
>     if(pid==0) { 
>       cat("Hi from the child process\n"); exit() 
>     } else {
>       cat("Hi from the parent process\n");
>     } 
>   } 
> }
> 
> }
> 
> which gets translated to 
> 
> \begin{Details}\relax
> This function provides a thin wrapper around the Unix "fork" system
> call, which will create a new process which is an exact copy of the
> [...]
> 
> \begin{verbatim}
>   \{
>     pid = fork(slave=NULL) 
>     if(pid==0) \{ 
>       cat("Hi from the child process\bsl{}n"); exit() 
>     \} else \{
>       cat("Hi from the parent process\bsl{}n");
>     \} 
>   \}
> \end{verbatim}\end{Details}
> 
> 
> When processed by Rd2dvi these warning messages show up in the log:
> 
> This is TeX, Version 3.14159 (Web2C 7.3.1) (format=latex 2002.7.17)  9 DEC
> 2003 16:11
> [...]
> 
> LaTeX Warning: Characters dropped after `\end{verbatim}' on input line 139.
> 
> [3] [4] [5] [6] [7] [8] [9]
> 
> ! LaTeX Error: \begin{list} on input line 73 ended by \end{document}.
> 
> See the LaTeX manual or LaTeX Companion for explanation.
> Type  H <return>  for immediate help.
>  ...                                              
>                                                   
> l.437 \end{document}
> [...]
> 
> The solution is to simply add an '\n' at the appropriate place in Rdconv.pm:
> 
> gsun492: R [61]> diff -u Rdconv.pm.orig Rdconv.pm
> --- Rdconv.pm.orig 2003-12-09 16:32:17.940846000 -0500
> +++ Rdconv.pm 2003-12-09 16:32:32.440931000 -0500
> @@ -2450,7 +2450,7 @@
>      my $code = $_[0];
>  
>      $code = latex_code_trans ($code);
> -    $code = "\\begin\{verbatim\}" . $code . "\\end\{verbatim\}";
> +    $code = "\\begin\{verbatim\}" . $code . "\\end\{verbatim\}\n";
>      $code;
>  }
> 
> after which everything works fine.
> 
> -Greg
> 
> 
> Gregory R. Warnes, Ph.D.
> Senior Coordinator
> Groton Non-Clinical Statistics
> Pfizer Global Research and Development
>  <<Warnes, Gregory R.vcf>> 
> 
> 
> LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}}
> 
> ______________________________________________
> 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] latex problem with \preformatted (PR#5645)
Prof Brian Ripley