Thank you for the prompt response!
It is probably important to mention that the .Rmd file works perfectly when run directly in RStudio or, when using rmarkdown::render()
in R console and runs perfectly from shiny when I suppress the code chunks for long tables, as described further.
Meanwhile I have detected and eliminated one source for this error, such as:
- I was using
noteMD
package to insert text edited with inputAreaText()
in shiny and observed that every time a hyphened or bulleted list of text items was used e.g.:
" Our findings show:
1. ldfjaslfklfdj
2. aljeoija
etc."
latex
would throw the abovementioned error.
I solved this issue by wrapping the noteMD
function with knitr::raw_latex()
function in the Rmd file. Code example below:
knitr::raw_latex(note_in_md_pdf(input$summary))
- The second issue refers to long tables (crossing multiple pages).
2.a For the table below:
kable(data1
, format = 'latex'
, caption = 'Samples In Study'
, booktabs = TRUE
, longtable = TRUE) %>%
column_spec(1, bold = TRUE, color = 'red') %>%
kable_styling(latex_options = c('hold_position', 'repeat_header')) %>%
kable_styling(font_size = 12)
both tinytex
and MikTex
throw similar error
! LaTeX Error: Illegal character in array arg.
2.b In the case of another long table the message changes:
I was unable to find any missing LaTeX packages from the error log ReportFulc.log.
! LaTeX Error: Environment longtabu undefined.
The code for the other long table is similar with the one shown above:
kable(data2
, format = 'latex'
, caption = 'p-values'
, align = 'l'
, booktabs = TRUE
, longtable = TRUE) %>%
kable_styling(font_size = 10) %>%
kable_styling(full_width = TRUE, latex_options = c('repeat_header', 'hold_position')) %>%
column_spec(1, bold = TRUE, color = 'red')
I have found out which package worked each time by running
for tinytex (having MikTex supressed):
> Sys.which('latex') latex
"C:\\Users\\Dragos\\AppData\\Roaming\\TinyTeX\\bin\\win32\\latex.exe"
for MikTex (tinytex probably still active):
> Sys.which('latex') latex
"C:\\PROGRA~1\\MiKTeX 2.9\\miktex\\bin\\x64\\latex.exe"
And finally:
> sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] noteMD_0.1.0 xfun_0.14 patchwork_1.0.0 ggplus_0.1 pander_0.6.4
[6] gridExtra_2.3 ggpubr_0.3.0 ggplot2_3.3.1 kableExtra_1.1.0 knitr_1.28
[11] rmarkdown_2.2 RMySQL_0.10.20 DBI_1.1.0 DT_0.13 data.table_1.12.9
[16] shiny_1.4.0.2
loaded via a namespace (and not attached):
[1] httr_1.4.1 tidyr_1.1.0 jsonlite_1.6.1 viridisLite_0.3.0
[5] carData_3.0-4 cellranger_1.1.0 yaml_2.2.1 pillar_1.4.4
[9] backports_1.1.7 lattice_0.20-41 glue_1.4.1 digest_0.6.25
[13] RColorBrewer_1.1-2 promises_1.1.0 ggsignif_0.6.0 rvest_0.3.5
[17] colorspace_1.4-1 htmltools_0.4.0 httpuv_1.5.3.1 pkgconfig_2.0.3
[21] broom_0.5.6 haven_2.3.1 purrr_0.3.4 xtable_1.8-4
[25] scales_1.1.1 webshot_0.5.2 openxlsx_4.1.5 later_1.0.0
[29] rio_0.5.16 tibble_3.0.1 farver_2.0.3 generics_0.0.2
[33] car_3.0-8 ellipsis_0.3.1 withr_2.2.0 magrittr_1.5
[37] crayon_1.3.4 readxl_1.3.1 mime_0.9 evaluate_0.14
[41] nlme_3.1-148 rstatix_0.5.0 forcats_0.5.0 xml2_1.3.2
[45] foreign_0.8-80 tools_4.0.0 hms_0.5.3 lifecycle_0.2.0
[49] stringr_1.4.0 munsell_0.5.0 zip_2.0.4 compiler_4.0.0
[53] tinytex_0.23.2 rlang_0.4.6 rstudioapi_0.11 htmlwidgets_1.5.1
[57] crosstalk_1.1.0.1 labeling_0.3 gtable_0.3.0 abind_1.4-5
[61] curl_4.3 readtext_0.76 R6_2.4.1 dplyr_1.0.0
[65] fastmap_1.0.1 shinythemes_1.1.2 readr_1.3.1 stringi_1.4.6
[69] Rcpp_1.0.4.6 vctrs_0.3.1 tidyselect_1.1.0