Gerrit Eichner
2014-Mar-05 12:32 UTC
[R] Sweave: cat() in a chunk with option results=tex doesn't producelinebreaks at the end of a character string anymore
Hello, everyone,
I am struggling with an Sweave-problem that didn't occur sofar (and I have
no clue what I might have changed in my system; see below). The following
example *.Rnw file's only task is (for simplicity) to output text with a
little bit of TeX-code with linebreaks (e. g., to be better readable):
\documentclass{article}
\begin{document}
Text 1 (not through cat()) followed by a double-backslash and
a blank line, i.e., a linebreak.\\
<<echo=FALSE, results=tex>>cat( "Text 2 (through cat()) with a
respected newline here\n",
"and likewise two tabs here\t\t followed by two double-backslashes
",
"and IGNORED newline escape characters at the end.\\\\ \n \n",
sep = "")
cat( "Text 3 (through cat()) just to finish this example and ",
"with also IGNORED newline escapes at its end. \n \n", sep =
"")
@
\end{document}
When processed by Sweave I obtain the following TeX file:
\documentclass{article}
\usepackage{Sweave}
\begin{document}
Text 1 (not through cat()) followed by a double-backslash and
a blank line, i.e., a linebreak.\\
Text 2 (through cat()) with a respected newline here
and likewise two tabs here followed by two
double-backslashes and IGNORED newline escape characters at the end.\\
Text 3 (through cat()) to finish this example and with also IGNORED
newline escapes at its end. \end{document}
the point being that the linebreaks (\n) at the ends of the output
character strings have been completely ignored.
I wasn't successful in searching the archive, RSeek, SE and the like. Any
idea where and how to continue to search, or what to do to get back
Sweave's "old" behavior (except for reinstalling R ... which of
course is
still an option)? Thanks for any hint!
Best regards -- Gerrit
PS:> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252
attached base packages:
[1] graphics grDevices utils datasets stats methods base
other attached packages:
[1] fortunes_1.5-2
loaded via a namespace (and not attached):
[1] grid_3.0.2 lattice_0.20-27 tools_3.0.2
---------------------------------------------------------------------
Dr. Gerrit Eichner Mathematical Institute, Room 212
gerrit.eichner at math.uni-giessen.de Justus-Liebig-University Giessen
Tel: +49-(0)641-99-32104 Arndtstr. 2, 35392 Giessen, Germany
Fax: +49-(0)641-99-32109 http://www.uni-giessen.de/cms/eichner
Duncan Murdoch
2014-Mar-05 13:53 UTC
[R] Sweave: cat() in a chunk with option results=tex doesn't producelinebreaks at the end of a character string anymore
On 05/03/2014 7:32 AM, Gerrit Eichner wrote:> Hello, everyone, > > I am struggling with an Sweave-problem that didn't occur sofar (and I have > no clue what I might have changed in my system; see below). The following > example *.Rnw file's only task is (for simplicity) to output text with a > little bit of TeX-code with linebreaks (e. g., to be better readable): > > > \documentclass{article} > \begin{document} > Text 1 (not through cat()) followed by a double-backslash and > a blank line, i.e., a linebreak.\\ > > <<echo=FALSE, results=tex>>> cat( "Text 2 (through cat()) with a respected newline here\n", > "and likewise two tabs here\t\t followed by two double-backslashes ", > "and IGNORED newline escape characters at the end.\\\\ \n \n", > sep = "") > > cat( "Text 3 (through cat()) just to finish this example and ", > "with also IGNORED newline escapes at its end. \n \n", sep = "") > @ > \end{document} > > > > When processed by Sweave I obtain the following TeX file: > > > \documentclass{article} > \usepackage{Sweave} > \begin{document} > Text 1 (not through cat()) followed by a double-backslash and > a blank line, i.e., a linebreak.\\ > > Text 2 (through cat()) with a respected newline here > and likewise two tabs here followed by two > double-backslashes and IGNORED newline escape characters at the end.\\ > Text 3 (through cat()) to finish this example and with also IGNORED > newline escapes at its end. \end{document} > > > the point being that the linebreaks (\n) at the ends of the output > character strings have been completely ignored.See the "strip.white" option in ?RweaveLatex. Duncan Murdoch> > I wasn't successful in searching the archive, RSeek, SE and the like. Any > idea where and how to continue to search, or what to do to get back > Sweave's "old" behavior (except for reinstalling R ... which of course is > still an option)? Thanks for any hint! > > Best regards -- Gerrit > > PS: > > sessionInfo() > R version 3.0.2 (2013-09-25) > Platform: x86_64-w64-mingw32/x64 (64-bit) > > locale: > [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 > [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C > [5] LC_TIME=German_Germany.1252 > > attached base packages: > [1] graphics grDevices utils datasets stats methods base > > other attached packages: > [1] fortunes_1.5-2 > > loaded via a namespace (and not attached): > [1] grid_3.0.2 lattice_0.20-27 tools_3.0.2 > > > > --------------------------------------------------------------------- > Dr. Gerrit Eichner Mathematical Institute, Room 212 > gerrit.eichner at math.uni-giessen.de Justus-Liebig-University Giessen > Tel: +49-(0)641-99-32104 Arndtstr. 2, 35392 Giessen, Germany > Fax: +49-(0)641-99-32109 http://www.uni-giessen.de/cms/eichner > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.