-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Difference in behavior for before/after_chapter_script
and new_session: true/false
#1252
Comments
I believe this is related to another thread #1049 Below is an attempt to detail the current situation! What happens when
|
Thanks for the detailed explanation and different solutions. That explains it to me. Furthermore, for my current project the possibility of specifying the size through the output format is completely sufficient. If I need more fine grained differentiation I would just do it chunk wise. However, I guess one remaining issue is that the current behaviour (i.e., the different ways Furthermore, the fact that the arguably most popular bookdown book, R4DS, also relies on this non-working behaviour maybe sets a bad example. I would assume I am probably not the only one basing ones configuration on the corresponding repository and then getting bitten by it. In any case, from my perspective this solves the issue. But I will leave it to you to close or not. Maybe updating the documentation somewhere is enough to ensure that it does not lead to too many people going bug hunting (i.e., I spend some time to nail down the exact situation in which it happens). |
Yes updating the documentation seems a good thing to do, thanks ! |
fig.width
(i.e., in knitr::opts_chunk()
) in _common.R
is ignored if new_session: true
before/after_chapter_script
and new_session: true/false
Sorry for the chunky title, but this seems to be a bug then only shows up in a very specific situation: If using the Knit-Merge strategy (i.e.,
new_session: true
in_bookdown.yml
) and abefore_chapter_script
(e.g.,_common.R
),fig.width
in thebefore_chapter_script
seems to be ignored. This does not seem to apply to other chunk options as far as I can tell, but particularly tofig.width
.fig.width
can also still be used directly in the chunk and works, but the global one is ignored.The easiest way to reproduce the bug is the following steps:
bs4_book
through theRStudio
menu interface (New Project
, ...). This ensures that_common.R
is present andnew_session: true
.index.Rmd
file:knitr
options in_common.R
to:Feel free to play around with
fig.width
and see that changing it does not change the width of the figure in the output, unless you changenew_session: true
tonew_session: false
in_bookdown.yml
or set it directly in the chunk. As far as I can tell the other figure options changed here (i.e.,out.width
andfig.asp
) seem to work.Also, this seems to be related to a comment in #36, #36 (comment)_
It also seems that an example of the bug can be found in the wild in the current version of "R for data science". At the moment, the width of the first figure in the data visualisation chapter is 1344 pixels. However, it appears it should be 1152 pixels because the
_common.R
file sets thefig.width
to6
(at least when settingfig.width
of a chunk to 7, I also get 1344, and with 6, 1152).My system:
The text was updated successfully, but these errors were encountered: