Open jooyoungseo opened 3 years ago
Hi believe this is a side effect of several changes in knitr, and it is a know issue with knitr: https://github.com/yihui/knitr/pull/1760
(When I reproduce you example, there is no caption for the two middle figures)
At first, fig.show='hold'
was not supported for office document (See https://github.com/rstudio/bookdown/issues/249#issuecomment-262358329) but this seems to have changed (in https://github.com/yihui/knitr/pull/1756). And there is still the issue mentioned above.
@atusy do you agree ? Do you think this is linked to what you worked on in the knitr package ?
I think there is also an issue with the counter in bookdown if two plots have the same caption label.
Yes, I agree.
However, if we expect a single caption for two middle figures, I don't know how. We will need some ooxml trick because figures are in a single line on the intermediate markdown, and Pandoc considers they are not captioned.
![cap1](fig1.png)![cap1](fig.png)
Yes I am not sure we can easily have the same output in HTML and Word. In docx, I am not even sure this is allowed to have one caption for several figure (without tricks) - It seems to me the built-in caption feature is per image. But maybe ooxml could help here as you said... This will require some thinking. 🤔
I wonder if officer
or officedown
handle this.
Another possibility is using custom-style
with Divs and Spans.
Captioned figures inherit the Captioned Figure
style, and their captions inherit the Image Caption
style.
You can see how the result would be by:
::: {custom-style="Captioned Figure"}
```{r, fig.show='hold'}
plot(1)
plot(2)
:::
::: {custom-style="Image Caption"} Caption :::
However, I am not sure if it is worth doing...
Personally, I would combine sub-figures by using **patchwork** package or **cowplot** package because
- it is more explicit that they are a set of figures, not individual ones.
- layout becomes more flexible.
- tagging is easyy (e.g., `(a)`, `(b)`, ...)
Personally, I would combine sub-figures by using patchwork package or cowplot package because
yes that would be a great advice IMO.
When
fig.show = "hold"
is used for multiple plots, figure counting result is different betweenhtml_document2
andword_document2
.Word output adds each count per sub figure whereas html only counts main plot.
Reprex
Test Rmd File
Rendering Results
Session Info
Created on 2020-11-08 by the reprex package (v0.3.0.9001)