Skip to content
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

Captions in pdf containing line breaks ("\n") #663

Open
4 tasks done
ian-curtis opened this issue Oct 3, 2024 · 1 comment
Open
4 tasks done

Captions in pdf containing line breaks ("\n") #663

ian-curtis opened this issue Oct 3, 2024 · 1 comment
Labels

Comments

@ian-curtis
Copy link

ian-curtis commented Oct 3, 2024

I am not sure if this is a flextable issue or not but I figured I'd start here. See the example below. Is "\n" not supported for pdf output? I checked ?set_caption and I see mostly notes in there about HTML and Word output. Should I be setting pdf captions a different way?

My .Rmd file....

---
title: "Flextable test"
date: "2024-10-03"
output:
  pdf_document:
    latex_engine: xelatex
---

'''{r}
library(flextable)
library(tibble)

tibble(
  x = seq(0, 10, 1),
  y = seq(100, 200, 10),
  z = seq(1000, 2000, 100)
) %>% flextable() %>% 
  set_caption(as_paragraph(as_chunk("Hey Hey This is the Caption \n Wow Another Line \n And Another Line")))
'''

....produces excellent HTML output....

Screenshot 2024-10-03 at 9 52 12 AM

....but has a funky pdf caption when knitted using knitr....

Screenshot 2024-10-03 at 9 53 03 AM

(Using bookdown::pdf_document2 produces this same issue).

Any thoughts? Maybe a piece of the manual or a closed issue I missed?

R version 4.4.1 (2024-06-14)
Platform: aarch64-apple-darwin20
Running under: macOS Sonoma 14.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Detroit
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] tibble_3.2.1    flextable_0.9.6

loaded via a namespace (and not attached):
 [1] vctrs_0.6.5             zip_2.3.1               cli_3.6.3               knitr_1.48             
 [5] rlang_1.1.4             xfun_0.47               textshaping_0.4.0       gdtools_0.4.0          
 [9] data.table_1.16.0       glue_1.7.0              openssl_2.2.2           askpass_1.2.0          
[13] htmltools_0.5.8.1       ragg_1.3.2              fansi_1.0.6             fontquiver_0.2.1       
[17] rmarkdown_2.28          grid_4.4.1              evaluate_1.0.0          fastmap_1.2.0          
[21] yaml_2.3.10             lifecycle_1.0.4         bookdown_0.40           compiler_4.4.1         
[25] officer_0.6.6           fontLiberation_0.1.0    pkgconfig_2.0.3         Rcpp_1.0.13            
[29] rstudioapi_0.16.0       systemfonts_1.1.0       digest_0.6.37           R6_2.5.1               
[33] utf8_1.2.4              pillar_1.9.0            magrittr_2.0.3          uuid_1.2-1             
[37] fontBitstreamVera_0.1.1 tools_4.4.1   

When submitting a new issue:

  • Provide the code that is producing the error, it has to be a minimal reproducible example.
    Stackoverflow is providing good explanations about it: https://stackoverflow.com/help/mcve. You can use package reprex to help you: http://reprex.tidyverse.org/. The most popular R stackoverflow question is about the subject: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example.

  • Provide the results of R command sessionInfo(). It had to be executed after you loaded the packages used by your example. This will let me know what is your version of R and what are the versions of the packages you used in your example.

  • Make sure you did checked you had the latest version of the package on CRAN (and on github if issue exists with CRAN version).

  • Make sure you searched in the open and closed issues on the github repository.

@davidgohel
Copy link
Owner

thanks, I can reproduce. I don't know what causes this weird alignment for now :(

@davidgohel davidgohel added the bug label Oct 10, 2024
@davidgohel davidgohel changed the title Captions in pdf output ignore line breaks ("\n") Captions in pdf containing line breaks ("\n") Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants