Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple logos, on different slides? #68

Open
giabaio opened this issue Oct 27, 2020 · 2 comments
Open

Multiple logos, on different slides? #68

giabaio opened this issue Oct 27, 2020 · 2 comments
Labels
type: question Question or troubleshooting

Comments

@giabaio
Copy link

giabaio commented Oct 27, 2020

Hi all,
Just a quick (hopefully!) question, mostly out of my ignorance of css... Is it possible to use use_logo repeatedly to change the logo? So, to be clearer, I have a set of slides I'm preparing when many speakers will talk - each from different institutions. So what I'd like to do is to be able to add the specific logo only in the slides that are relevant for a given speaker.

I think if I use multiple chunks pointing to different images, then the last one will take over and be included even when it shouldn't (on top of the "correct" one)? I suppose I could define a class for each speaker and the add all the "other" classes to the call to use_logo, but I was wondering whether there's a neater option?

Thanks!
Gianluca

@gadenbuie
Copy link
Owner

Hi @giabaio ... unforunately use_logo() is designed around inserting one logo into all of the slides.

But the good news is that you can use plain CSS to accomplish something very similar:

image

Add this block to your slides (near the top) or add the CSS to a separate CSS file that you load in the css option of moon_reader in the YAML header:

```{css, echo=FALSE}
.with-logo::before {
	content: '';
	width: 110px;
	height: 126px;
	position: absolute;
	top: 0.5em;
	right: 0.5em;
	background-size: contain;
	background-repeat: no-repeat;
}
.logo-dplyr::before {
	background-image: url(https://github.com/rstudio/hex-stickers/raw/master/PNG/dplyr.png);
}
.logo-purrr::before {
	background-image: url(https://github.com/rstudio/hex-stickers/raw/master/PNG/purrr.png);
}
.logo-plumber::before {
	background-image: url(https://github.com/rstudio/hex-stickers/raw/master/PNG/plumber.png);
}
```

Change the names of the .logo- classes and the URLs of the images. Then, for each slide that needs a logo, add the with-logo class and the specific logo class, e.g. logo-dplyr.

Here's the complete source code for the example similar to the screenshot above.

---
title: Slides with Multiple Logos
output:
  xaringan::moon_reader:
    lib_dir: libs
    seal: false
    nature:
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
---

class: center middle with-logo logo-dplyr

# dplyr

---

class: center middle with-logo logo-purrr

# purrr

---

class: center middle with-logo logo-plumber

# plumber

```{css, include=FALSE}
.with-logo::before {
	content: '';
	width: 110px;
	height: 126px;
	position: absolute;
	top: 0.5em;
	right: 0.5em;
	background-size: contain;
	background-repeat: no-repeat;
}
.logo-dplyr::before {
	background-image: url(https://github.com/rstudio/hex-stickers/raw/master/PNG/dplyr.png);
}
.logo-purrr::before {
	background-image: url(https://github.com/rstudio/hex-stickers/raw/master/PNG/purrr.png);
}
.logo-plumber::before {
	background-image: url(https://github.com/rstudio/hex-stickers/raw/master/PNG/plumber.png);
}
```

@gadenbuie gadenbuie added the type: question Question or troubleshooting label Oct 27, 2020
@giabaio
Copy link
Author

giabaio commented Oct 27, 2020

Thank you @gadenbuie !
Seems to be working fine. Awesome.

Only thing is you just need to add the class: xxx bit to every single slide, but other than that works perfectly.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Question or troubleshooting
Projects
None yet
Development

No branches or pull requests

2 participants