Reputation: 5508
Can I add more than one custom css file into R Markdown file?
I found that, add the following code in the head, I can add a customer css file.
html_document:
css: /css/my1.css
But this method just allowed one css file. Is it possible add more than one customer css file into a Rmd file?
Upvotes: 3
Views: 638
Reputation: 52637
By poring through the sources I eventually figured out that the output
portion of the Rmd headers can be specified as an R function. Here is a header I use as part of my diffobj
package to get two CSS files in:
---
title: "diffobj - Diffs for R Objects"
author: "Brodie Gaslam"
output:
function(...) rmarkdown::html_vignette(..., md_extensions="-markdown_in_html_blocks", css=c(file.path(system.file(package="diffobj"), "css", "diffobj.css"), "styles.css")):
toc: true
vignette: >
%\VignetteIndexEntry{diffobj}
%\VignetteEngine{knitr::rmarkdown}
\usepackage[utf8]{inputenc}
---
You can skip the md_extensions
part for your purposes. The key is what happens with the css
argument. With that argument I specify the following two files:
file.path(system.file(package="diffobj"), "css", "diffobj.css")
, from my package"styles.css"
, in the same folder as the vignette RmdThe above is in the context of using devtools::build_vignettes()
, but I imagine you can use a similar solution in your situation.
Upvotes: 2