rstudio / rmarkdown-cookbook

R Markdown Cookbook. A range of tips and tricks to make better use of R Markdown.
https://bookdown.org/yihui/rmarkdown-cookbook/
584 stars 225 forks source link

How to have subfigure in Latex ouput #142

Closed cderv closed 5 years ago

cderv commented 5 years ago

use package subcaption from Latex https://github.com/yihui/knitr-examples/blob/master/104-subfigure.Rnw

dr-harper commented 5 years ago

Not sure whether this has been sufficiently covered in this post: https://dr-harper.github.io/rmarkdown-cookbook/latex-subfigures.html

The current solution uses the subfig package. It might be one of those cases where there are multiple packages which do a similar thing in LaTeX with little difference. This post suggests that subcaption might be a better way forward.

Will try playing around with this to see.

dr-harper commented 5 years ago

Right, having played around with this I think I am going to leave it out. Knitr only has built in support for the subfig package, as explained by Yihui

fig.subcap: (NULL) captions for subfigures; when there are multiple plots in a chunk, and neither fig.subcap nor fig.cap is NULL, \subfloat{} will be used for individual plots (you need to add \usepackage{subfig} in the preamble); see 067-graphics-options.Rnw for an example.

I am trying to avoid using the .Rnw format throughout the book. I think it is generally more confusing for new users and there is limited merit to using this format when you can used .Rmd.

I will let you close the issue if you are happy 😄actually, I have been thinking that we should make it habit that if one of us posts a solution to an issue, we should let the other person close it out. That way we can make sure that both of us are happy with the change.

cderv commented 5 years ago

Thanks for testing. One way to do it is enough.

And several knitr example are old and concerns Rnw. It is not obvious of they are still suitable for Rmd. This book and repo will clarify that.

cderv commented 5 years ago

I have been thinking that we should make it habit that if one of us posts a solution to an issue, we should let the other person close it out. That way we can make sure that both of us are happy with the change.

And I agree on that.

piiskop commented 10 months ago

How to increase spacing between subfigures? The subcaptions have no space in between.