I have an R Markdown document in which every top level heading needs the same five lines of code before it to make the formatting nice. I want to know if I can set these five lines in a style.css
or latex document (or otherwise externally to the R Markdown document) rather than repeat them every time.
An example of what my R Markdown looks like at the moment - some whitespace and a line, and a \newpage
so it prints nicely:
<br>
<br>
***
<br>
<br>
\newpage
# Heading 1
content
<br>
<br>
***
<br>
<br>
\newpage
# Heading 2
content
<br>
<br>
***
<br>
<br>
\newpage
# Heading 3
content
It seems like bad practice (and it's annoying) to keep repeating those five lines. It also means I'm mixing up formatting and content, which I'd prefer to avoid.
I already use a style.css
file for other aspects of formatting the HTML output. I'm wondering if I can use it to do this too? Failing that, perhaps in a latex document?
Either solution would have the obvious advantages of both cleaning up my R Markdown, as well as making it simpler to adjust the formatting if I want to. (I use the same style.css
for multiple related documents).
The closest I have found is this:
Level 4 Heading issue in R Markdown
but I know nothin about latex documents and HTML, and am hoping there's a css solution too.
"}` ... if you insist on using linebreaks instead of proper CSS like `h1{margin-top:2em}`, that is ;-) – I_O May 21 '23 at 07:57