rmarkdown icon indicating copy to clipboard operation
rmarkdown copied to clipboard

A new suboption of the includes option [FR]

Open GauSyu opened this issue 2 years ago • 1 comments

Is it possible to add a new suboption of the includes option other than in_header, before_body, and after_body. The new suboption should add the specified file(s) to the preamble immediately after the documentclass sentence.

Why one may need this feature? The reason is some LaTeX packages are sensitive to their loading order and unfortunately when file(s) in in_header be added to the preamble, some packages such as amsmath and unicode-math have already been loaded. It is too late to load packages that should be loaded before them.

GauSyu avatar Apr 10 '23 23:04 GauSyu

Thanks for the suggestion. The includes in rmarkdown currently rely directly on Pandoc's feature. The possible includes are the one available in the template - https://pandoc.org/MANUAL.html#variables-set-automatically

Did you share this idea already in Pandoc's discussion list or issue board ? If this was supported upstream, this would be possible to add support in here.

Currently, we are not tweaking the LaTeX template anymore - adding a new Pandoc unsupported option like this would require us to maintain patched templates from Pandoc. We could consider it or see if we can dynamically patch the default templates 🤔

Also, note that newest project extending R Markdown called Quarto https://quarto.org/ does handle the templating customisation better by allowing partial modification of the default templates. Different project though, with some redesigned feature and the benefit of starting fresh on some stuff.

I'll add the enhancement label to consider this for later version of rmarkdown.

cderv avatar Apr 11 '23 09:04 cderv