New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chunk that does not produce any output generates two empty lines in LaTeX output #231

Closed
krlmlr opened this Issue May 15, 2012 · 9 comments

Comments

2 participants
@krlmlr
Contributor

krlmlr commented May 15, 2012

The following minimal.Rnw input file

\documentclass{article}
\begin{document}
a
<<q,echo=FALSE,results='hide'>>=
getwd()
@
b
\end{document}

generates on output (using R --no-save <<<"library(knitr); knit('minimal.Rnw')" in a bash shell)

% ... header stripped for brevity
\begin{document}
a


b
\end{document}

That's two empty lines too much for my understanding. Sweave used to leave out these empty lines.

Is this a bug or a (hopefully configurable) feature?

@krlmlr

This comment has been minimized.

Show comment
Hide comment
@krlmlr

krlmlr May 15, 2012

Contributor

There's a workaround that consists of defining a command that gobbles all following empty lines:

http://tex.stackexchange.com/questions/55914/command-that-gobbles-all-following-empty-lines

Contributor

krlmlr commented May 15, 2012

There's a workaround that consists of defining a command that gobbles all following empty lines:

http://tex.stackexchange.com/questions/55914/command-that-gobbles-all-following-empty-lines

@yihui

This comment has been minimized.

Show comment
Hide comment
@yihui

yihui May 16, 2012

Owner

I do not know if this is a bug, and unfortunately this is not configurable. Why do you want to remove the two empty lines? Because it makes a and b separate paragraphs?

Owner

yihui commented May 16, 2012

I do not know if this is a bug, and unfortunately this is not configurable. Why do you want to remove the two empty lines? Because it makes a and b separate paragraphs?

@krlmlr

This comment has been minimized.

Show comment
Hide comment
@krlmlr

krlmlr May 17, 2012

Contributor

Exactly. If I want to back up a written sentence in a report with an R assertion, I want to keep both next to each other.

Contributor

krlmlr commented May 17, 2012

Exactly. If I want to back up a written sentence in a report with an R assertion, I want to keep both next to each other.

@yihui

This comment has been minimized.

Show comment
Hide comment
@yihui

yihui May 18, 2012

Owner

Fair enough. Can you move the chunk before a or after b? Since you do not want to output anything from the chunk, moving it might not hurt.

Owner

yihui commented May 18, 2012

Fair enough. Can you move the chunk before a or after b? Since you do not want to output anything from the chunk, moving it might not hurt.

@krlmlr

This comment has been minimized.

Show comment
Hide comment
@krlmlr

krlmlr May 18, 2012

Contributor

Yes, I could, but I prefer keeping code and text as close as possible to each other. For now, I use a TeX macro that gobbles all following empty lines to achieve what I want, see the link in one of my former comments.

Contributor

krlmlr commented May 18, 2012

Yes, I could, but I prefer keeping code and text as close as possible to each other. For now, I use a TeX macro that gobbles all following empty lines to achieve what I want, see the link in one of my former comments.

@yihui

This comment has been minimized.

Show comment
Hide comment
@yihui

yihui May 22, 2012

Owner

The main reason that I do not want to change this is due to the concordance feature. It requires a little bit more careful thinking; I will think about it later.

Owner

yihui commented May 22, 2012

The main reason that I do not want to change this is due to the concordance feature. It requires a little bit more careful thinking; I will think about it later.

@yihui

This comment has been minimized.

Show comment
Hide comment
@yihui

yihui May 26, 2012

Owner

I decided not to change this. Sorry.

Owner

yihui commented May 26, 2012

I decided not to change this. Sorry.

@yihui yihui closed this May 26, 2012

@krlmlr

This comment has been minimized.

Show comment
Hide comment
@krlmlr

krlmlr May 26, 2012

Contributor

No problem, I'm fine with the workaround. You might want to list this behavior (and a hint how to work around it) in your documentation somewhere. Please feel free to use the code in the TeX.SX answer.

Contributor

krlmlr commented May 26, 2012

No problem, I'm fine with the workaround. You might want to list this behavior (and a hint how to work around it) in your documentation somewhere. Please feel free to use the code in the TeX.SX answer.

@yihui

This comment has been minimized.

Show comment
Hide comment
@yihui

yihui May 27, 2012

Owner

Thanks!

Owner

yihui commented May 27, 2012

Thanks!

yihui added a commit that referenced this issue Jun 5, 2012

yihui added a commit that referenced this issue Oct 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment