[Rd] latex problem with \preformatted (PR#5645)
gregory_r_warnes at groton.pfizer.com
gregory_r_warnes at groton.pfizer.com
Tue Dec 9 22:34:48 MET 2003
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}}
More information about the R-devel
mailing list