[R] Sweave: superfluous newline (`\\') in tex file

Patrick Drechsler patrick.drechsler at gmx.net
Sun Sep 26 14:24:31 CEST 2004


Hi,

I'm having trouble sweaving the following example:

--8<------------------------schnipp------------------------->8---
\documentclass{article}
\begin{document}
\SweaveOpts{echo=FALSE}
@ 
<<>>=
rm(list=c(ls()))
library(Hmisc)
library(ISwR)
data(energy)
energy$log <- log(energy$expend)
attach(energy)
@ %def 

@ 
<<results=tex>>=
mysum <- summary(stature ~ expend + log, method="reverse", test=T)
latex(mysum, file='',
      caption="foo bar",
      label="tab:foobar"
      )
@ %def 

\end{document}
--8<------------------------schnapp------------------------->8---

Here's the resulting tex file (sorry for the long lines):

--8<------------------------schnipp------------------------->8---
\documentclass{article}
\usepackage{/usr/local/lib/R/share/texmf/Sweave}
\begin{document}


% latex.default(cstats, title = title, caption = caption, rowlabel = rowlabel,      col.just = col.just, numeric.dollar = FALSE, insert.bottom = legend,      rowname = lab, dcolumn = dcolumn, extracolheads = extracolheads,      extracolsize = Nsize, ...) 
%
\begin{table}[!tbp]
 \caption{foo bar\label{tab:foobar}} 
 \begin{center}
 \begin{tabular}{lccc}\hline\hline
\multicolumn{1}{l}{}&
\multicolumn{1}{c}{lean}&
\multicolumn{1}{c}{obese}&
\multicolumn{1}{c}{Test Statistic}
\\   &\multicolumn{1}{c}{{\scriptsize $N=13$}}&\multicolumn{1}{c}{{\scriptsize $N=9$}}&\\ \hline
expend&{\scriptsize  7.48~}{ 7.90 }{\scriptsize  8.11} &{\scriptsize  9.21~}{ 9.69 }{\scriptsize 11.51} &$ F_{1,20}=17 ,~ P<0.001  $\\
log&{\scriptsize 2.012233~}{2.066863 }{\scriptsize 2.093098} &{\scriptsize 2.220290~}{2.271094 }{\scriptsize 2.443216} &$ F_{1,20}=17 ,~ P<0.001  $\\
\hline
\end{tabular}

\end{center}

\noindent {\scriptsize $a$\ }{$b$\ }{\scriptsize $c$\ } represent the lower quartile $a$, the median $b$, and the upper quartile $c$\ for continuous variables.\\

 \\ %% <- ERROR!
 

 Test used: Wilcoxon test
\end{table}
\end{document}
--8<------------------------schnapp------------------------->8---

And here's the error message:

,----
| ERROR: LaTeX Error: There's no line here to end.
| 
| --- TeX said ---
| 
| See the LaTeX manual or LaTeX Companion for explanation.
| Type  H <return>  for immediate help.
|  ...                                              
|                                                   
| l.27 
|      
| --- HELP ---
| A \newline or \\ command appears between paragraphs, where it
| makes no sense. If you're trying to ``leave a blank line'', use
| a \vspace command.
`----

Is there a way to suppress the extra newline `\\' without editing
the Rnw file? I couldn't find anything in the archives
describing this problem.

TIA,

Patrick

Versions:

Thorsten's noweb-mode (PRERELEASE). RCS: $Id: noweb-mode.el,v 1.14 2002/06/20 21:52:06 rsparapa Exp $

Emacs  : GNU Emacs 21.3.50.6 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2004-09-07 on trurl
Package: ess-mode 5.2.3

R : Copyright 2004, The R Foundation for Statistical Computing
Version 1.9.1 alpha (2004-06-07), ISBN 3-900051-00-3


-- 
"I'm all in favor of keeping dangerous weapons out of the hands of
fools. Let's start with typewriters." 
    -- Frank Lloyd Wright (1868-1959)




More information about the R-help mailing list