One distinction between knitr
and Sweave
is that the former forcibly inserts two empty lines in the generated TeX source for chunks that do not do any output.
I'm not sure if this issue is a bug or a feature, but for now I'm looking for a workaround.
The problem can be summarized as follows: .Rnw
code like
a
<<q,echo=FALSE,results='hide'>>=
getwd()
@
b
produces LaTeX code like
a
b
where the space between a
and b
is not always desired. The best workaround that I found so far is to write
a\q{
<<q,echo=FALSE,results='hide'>>=
getwd()
@
}b
and define \q
as a one-parameter command that expands to a single space. Is there a shorter way to achieve a similar result, perhaps without using braces and without affecting the line that starts with b
?
ADDED: Is there a way to assign to a special character, say, §
, the semantics of this command, so that the following will work:
a §
<<q,echo=FALSE,results='hide'>>=
getwd()
@
b
(Of course, a knitr
way to achieve this would be most welcome, too.)
This answer seems related, but I haven't been able to get the \eatpar
command to work. Would it eat two empty lines, too?