Skip to content
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 · 10 comments
Closed
Labels
next Issues/PRs considered for the next release

Comments

@krlmlr
Copy link
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
Copy link
Contributor Author

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
Copy link
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
Copy link
Contributor Author

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
Copy link
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
Copy link
Contributor Author

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
Copy link
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
Copy link
Owner

yihui commented May 26, 2012

I decided not to change this. Sorry.

@yihui yihui closed this as completed May 26, 2012
@krlmlr
Copy link
Contributor Author

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
Copy link
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
@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
next Issues/PRs considered for the next release
Projects
None yet
Development

No branches or pull requests

2 participants