fix disappearance of figure captions when a chunk generates multiple figures continuously #1760
+90
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Knitr generates multiple figures in one line when a chunk generates multiple figures continuously.
For example,
becomes something like
In such case, Pandoc will suppress figure captions.
Yihui pointed out this in #1756 and I did in #1755 .
These issues were about office formats, but the issue occurs also in HTML and PDF.
I think users expect figure captions be shown rather than figures stay in one line.
This PR fixes this problem by adding blank lines between captioned figures.
The current implementation requires
fig.show='hold'
orecho=FALSE
, which is maybe too strict becauseis still like
Unfortunately, I have no idea how to detect such a case.
A workaround is to add blank lines regardless of what is specified to
fig.show
andecho
.A disadvantage of the workaround is that needless blank lines will be added when multiple figures are generated by a chunk but are separated from each other by something, i.e.
will be like
IMO, For the most of the formats, this is okay because the markdown format is just the intermediate format.
Some may dislike the needless blank lines when they want the markdown format as the output format.
Any thoughts?
Example Rmd