gadenbuie / xaringanthemer

😎 Give your xaringan slides some style

Home Page:https://pkg.garrickadenbuie.com/xaringanthemer/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ignoring xaringan-themer.css

andrewpbray opened this issue · comments

A small question about best practice: would you recommend adding xaringan-themer.css to .gitignore for a repo that uses the package? Ordinarily, I'd commit something like this to make it easily nabbable by other users, but it seems like the package effectively makes this a temp file.

And a note of praise: I think this package may have solved a persistent thorn in my side. I've never been able to figure out a way to: a) maintain a css that I can easily access across documents in different directories/repos while b) making any .Rmd that I hand off to someone else able to access the same css without needing an additional package. My solution was to create a package for personal use containing Rmd templates that include in their first r setup chunk source an external r script.

---
title: ""
subtitle: ""
author: "Andrew Bray"
output:
  xaringan::moon_reader:
    css: xaringan-themer.css
    lib_dir: libs
    nature:
      highlightStyle: atelier-forest-light
      highlightLines: true
      highlightSpans: true
      countIncrementalSlides: false
---

```{r setup, include=FALSE}
source("https://raw.githubusercontent.com/andrewpbray/stitched/master/demos/slides_css.R")

Although it's a bit wonky, I decided to put the css-generating script in the /demos directory:

xaringanthemer::style_mono_accent(
  base_color = "#1c5253",
  header_font_google = xaringanthemer::google_font("Josefin Sans"),
  text_font_google   = xaringanthemer::google_font("Montserrat", "300", "300i"),
  code_font_google   = xaringanthemer::google_font("Fira Mono")
)

There may well be a better structure for solving this problem, but I wasn't able to crack it until this package came along - thanks!

Hi Andrew, glad you've been enjoying the package! The use case of making the slide's .Rmd more self-contained was really what kicked this project off for me. That and wanting to be able to choose a primary color and have it used in several different places at once.

It's completely possible to write even very complicated CSS files using one call to a xaringanthemer style function. But I've found that in general I do something very similar to your second solution: for themes that I want to re-use frequently, I'll create them initially with xaringanthemer but then build a small package around the template. Although, if the theme is unlikely to change then I'll store the theme's CSS file with the skeleton as a static file rather than generating it with xaringanthemer.

Thanks again for sharing your use case, I'm always happy to hear about how the package is being used!