Skip to content

Centering incomplete when using subfig in markdown with out.width < "100%" #2518

Closed
@slrellison

Description

@slrellison

Using subfig as in bookdown 6.6, with fig.ncol=1, fig.align="center" and out.width="80%" (for example), the final subfigure is not aligned with previous figures.

Inspection of the LaTeX shows that this is due to a missing \newline after the final subfigure; inserting it manually in the LaTeX output corrects the alignment.

Reprex based on section 6.6 example:

---
output: 
  pdf_document:
    extra_dependencies: "subfig"
    keep_tex: yes
---

```{r, fig.cap='Figure 1', fig.dim=c(7,3), fig.ncol=1, fig.align = "center", out.width="80%", fig.cap="Minimal example; note the misalignment of (c) on compilation to pdf", fig.subcap=c('First', 'Second', 'Third')}
plot(1:10)
plot(cars, pch = 19)
boxplot(Sepal.Width ~ Species, data = iris)
```


Session info:

xfun::session_info('rmarkdown')
R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045), RStudio 2023.6.1.524

Locale:
LC_COLLATE=English_United Kingdom.utf8 LC_CTYPE=English_United Kingdom.utf8
LC_MONETARY=English_United Kingdom.utf8 LC_NUMERIC=C
LC_TIME=English_United Kingdom.utf8

time zone: Europe/London
tzcode source: internal

Package version:
base64enc_0.1.3 bslib_0.5.1 cachem_1.0.8 cli_3.6.1
digest_0.6.33 ellipsis_0.3.2 evaluate_0.21 fastmap_1.1.1
fontawesome_0.5.2 fs_1.6.3 glue_1.6.2 graphics_4.3.1
grDevices_4.3.1 highr_0.10 htmltools_0.5.6 jquerylib_0.1.4
jsonlite_1.8.7 knitr_1.43 lifecycle_1.0.3 magrittr_2.0.3
memoise_2.0.1 methods_4.3.1 mime_0.12 R6_2.5.1
rappdirs_0.3.3 rlang_1.1.1 rmarkdown_2.24 sass_0.4.7
stats_4.3.1 stringi_1.7.12 stringr_1.5.0 tinytex_0.46
tools_4.3.1 utils_4.3.1 vctrs_0.6.3 xfun_0.40
yaml_2.3.7

Pandoc version: 3.1.1


  • [YES ] installed and tested your bug with the development version of the rmarkdown package using remotes::install_github("rstudio/rmarkdown")?
    [Checked after initial session Info above]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions