Open grimbough opened 2 years ago
This is definitely a bit odd. I can reproduce the issue if if compile the document using Rscript -e 'rmarkdown::render()'
but it builds fine if I press the 'knit' button in Rstudio.
This is because I'm dumb and didn't notice that the default is BiocStyle::html_document
so pressing the knit button is doing something else entirely.
I'm beginning to think this is an oddity (bug?) in rmarkdown. Consider the following Rmd:
---
title: "Vignette Title"
output:
BiocStyle::pdf_document
---
Using the `images = "lowres"` is fine.
This will render fine with
rmarkdown::render("test.Rmd")
#> ...
#> Output created: test.pdf
However it fails when supply an output_file
argument, even if that is the same as the default e.g.
rmarkdown::render("test.Rmd", output_file = "test.pdf")
#> ....
#> ! Package soul Error: Reconstruction failed.
That is a really weird oddity / bug in rmarkdown
! Thanks for figuring out a tiny reprex
! Should I report this at rmarkdown
? Or do you want to? Aka, you might have other details / hints that could help them resolve this.
I'm not sure it's really a bug in rmarkdown. The patch for the soul
issues is executed a post-processing step to the intermediate markdown file, before it is converted to PDF. However when you specify a PDF output file name it does the conversion first and fails because the patch hasn't been applied. I'm currently not sure if there's some quirky behaviour in rmarkdown or if BiocStyle is using some hack which this particular usecase exposes.
If you want more unexpected behaviour, try this:
rmarkdown::render("test.Rmd", output_file = "AdditionalFile.tex")
Hmm I see. I have no idea either and well, my natural inclination would be to ask the rmarkdown
authors for help.
I searched for output_file
at https://github.com/rstudio/rmarkdown/blob/main/R/render.R and well nothing really pops to me. Like https://github.com/rstudio/rmarkdown/blob/main/R/render.R#L1000-L1006 calls https://github.com/Bioconductor/BiocStyle/blob/master/R/pdf_document.R#L146-L163, right? But I can't spot anything that would indicate an issue with the output_file
isn't the default NULL
and thus triggers by default https://github.com/rstudio/rmarkdown/blob/main/R/render.R#L487-L491.
I've drafted an issue on the rmakdown repo, but I haven't posted as I want to check it isn't us doing a dirty hack & then blaming someone else. I'll do some more digging and then post it.
I've posted an issue with the current state of my investigations. In the interim, you can actually get the desired behaviour by providing an output file name without an extension e.g.
> rmarkdown::render("test.Rmd", output_file = "test1")
Warning: LaTeX Warning: You have requested package `/mnt/data/R-lib/4.1.1-bioc_3.14/Bioc
Warning: Style/resources/tex/Bioconductor',
Warning: but the package provides `Bioconductor'.
Warning: Package geometry Warning: Over-specification in `h'-direction.
Warning: `width' (384.1122pt) is ignored.
Warning: Package Fancyhdr Warning: \fancyhead's `E' option without twoside option is use
Warning: less on input line 162.
Output created: test1.pdf
Hi,
In my case, I ran into another error using the files from https://github.com/LieberInstitute/spatialLIBD/tree/RELEASE_3_14.
Failed outputs are at: Archive.zip
I don't get the error with:
AdditionalFile1.pdf
R session info
With small example it does work
However, with the small test case it does work. I edited the small example above to use
sessioninfo::session_info()
instead ofsessionInfo()
.test.Rmd
contents:PDF result:
test.pdf
Originally posted by @lcolladotor in https://github.com/Bioconductor/BiocStyle/issues/89#issuecomment-996929162