-
Maybe I missed an option to do this, but I'm thinking it would be nice if we could specify in the Yaml header a script to be executed at the start of the knitting process (I'm using R/knitr as a concrete example, but the same idea would presumably apply to other engines). Unlike pre-render project scripts, the purpose here is would be to set up the environment for the computations, e.g loading packages, setting options, doing some calculations for use in subsequent chunks, etc. Of course, this is trivially achieved with a first chunk,
but there are some types of prose-first documents where I would prefer to have this happen less prominently, as a background process, rather than the first thing that I read when I work on the document. I find it a bit distracting, when writing prose, to be facing first not the abstract, or the first section title, introduction, etc. but obscure lines of code that are not necessarily things I should be thinking about, and which inadvertently force my brain to switch to coding mode, so to speak. I would rather have an option in the header,
I ran into this when creating CVs, posters, exam papers, cover letters, etc. in Quarto; for these types of output the computations, often minimal, are there in the background to support the document and help construct it (e.g grabbing size information from image files, etc.), but I want to see them as little as possible. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
It's unlikely that we'll do this because it requires working uniformly across engines. But if your main concern is readability, you can start with an include shortcode:
and then
|
Beta Was this translation helpful? Give feedback.
-
Just adding some other solutions for knitr users having a R file to run as a setup chunk (to complement other answer in this thread) The ```{r}
#| label: setup
#| echo: false
#| file: setup.R
``` This can be added in all chapter. Using A R only workaround for auto running some R code before any R code is using a project .Rprofile. Quarto will start a new R process for each document, and it is possible to leverage R own startup feature for this. Advanced User only I would say but quite valid anyway. To learn more: https://rstats.wtf/r-startup.html |
Beta Was this translation helpful? Give feedback.
It's unlikely that we'll do this because it requires working uniformly across engines. But if your main concern is readability, you can start with an include shortcode:
and then
preamble.md
has ther
code cell: