Search code examples
rr-markdownxaringan

Include filepath for css file in R Markdown YAML


I need to link my R Markdown to a css file. If the css file is in the same directory as the .Rmd file, it works without problems. If the css is in a different directory, it does not work.

How do I include a file path in the css field of my YAML?

This does not work

---
title: "MY TITLE"
author: "MY NAME"
output:
  xaringan::moon_reader:
    lib_dir: libs
    css: path/to/xaringan_themer.css
    nature:
      highlightStyle: tomorrow-night-bright
      highlightLines: true
      countIncrementalSlides: false
      titleSlideClass: ["center","top"]
---

Solution

  • So I explore this topic which is a "hot" one for years.
    The last news is a new issue which pointing out all previous one and offers a solution https://github.com/rstudio/rmarkdown/issues/1859. Author stating that his branches https://github.com/jonathan-g/rmarkdown/tree/jg-devel and https://github.com/jonathan-g/rmarkdown/tree/minimal-tree-fix (this last one is pruning my changes down to a minimal patch to keep the PR small) offers a solution for this problem. The PR is still not exists at this point, with the last update a few months ago.

    Other solution (which i like) might be usage of symlinks, presented here: https://github.com/jdblischak/workflowr/issues/95#issuecomment-360138007 What is important, symlinks are supported by git. Example at https://github.com/stephenslab/wflow-divvy/tree/dev under organized dir.