Is it possible to add an image to the title page of ioslides presentation?
I would like to add a big logo after the instead of xyz.
---
title: "Empowering Data-Driven Decisions at <br> xyz"
author: Omayma Said
date: Jan 11, 2017
output: ioslides_presentation
---
Yes. There is a standard option to include a small logo included in the ioslides bookdown documentation as well as some code to make a custom size image using css. This css can go in a separate document or it can at the start of your document after the YAML header which is typically easier when you only have a few lines to add.
Here is an example of putting the css in the document using code snippets from the bookdown documentation.
---
output:
ioslides_presentation:
logo: logo.png
---
<script>
.gdbar img {
width: 300px !important;
height: 150px !important;
margin: 8px 8px;
}
.gdbar {
width: 400px !important;
height: 170px !important;
}
slides > slide:not(.nobackground):before {
width: 150px;
height: 75px;
background-size: 150px 75px;
}
</script>
# Transition slide
## First slide
Yes, it is possible with the help of css.
First step is to add the css in the output of the markdown:
---
title: "Your <br> Title"
author: "Author Name"
date: "<div class = 'slide-date'>`r format(Sys.Date(),format='%B %Y')` <div>"
output:
ioslides_presentation:
css: styles.css
---
The next step is to add the image in your styles.css file
slides>slide.title-slide {
background-image: url('title_image.png');
background-size: 100% 100%;
}
Happy Coding!
Related
Just recently i found out about marp.
I want to customize it a little to have basically 4 types of slides.
The title slide and the ToC slide should have different background images.
Following this post, i was able to customize the headings for those slides:
https://www.syndikat7.de/de/post/software-engineers-approach-to-presentation-slides
section.title h1 {
font-size: 60px;
letter-spacing: 10px;
margin-bottom: 0;
padding-bottom: 0;
}
---
marp: true
theme: mytheme
---
<!-- _class: title -->
# My heading on title themed slide
Now i want to add a cutom background image for the whole slide to this Class only.
But where do i have to but the background-image: url('PAth\to\image.png);?
if i put it in
section.title {
justify-content: center;
background-image: url('PAth\to\image.png);
}
The image just shows up around the actual title. The slid backglround is unaltered.
I am trying to display some regression results in an rmarkdown html file. However, the output from the code chunks is too narrow and therefore it is very hard to read the p-values, etc, particularly when I include a floating table of contents. I have tried adjusting options(width = 9999) but this does not seem to fix the issue. I have also tried:
<style>
pre {
overflow-x: auto;
}
pre code {
word-wrap: normal;
white-space: pre;
}
</style>
which allows me to scroll horizontally if needed. However, given I am using regression results, I do not like having to scroll back and forth to read the coefficients and p-values. I have also tried:
<style>
.main-container { width: 1200px; max-width:2800px;}
</style>
adjusting the width and max-width values, to no avail. These solutions are suggested here.
Any idea how I can solve this issue?
Here is an example. Unfortunately I cannot post my regression results, so here is a matrix that essentially replicates the same issue:
---
title: "Untitled"
author: "me"
date: "11/10/2021"
output:
html_document:
toc: true
tow_float: true
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
options(width = 9999)
matrix = matrix(rnorm(100,5,2), ncol = 20)
matrix
However, when I knit the document, I get something like this:
How can I make the output wider?
I found out, where is your problem.
The floating toc is guilty.
Look, I took a code from that post and remove toc_float.
---
title: "R Notebook"
author: "me"
date: "11/10/2021"
output:
html_document:
toc: true
---
<style>
.main-container { width: 1800px; max-width:2800px;}
</style>
## R Markdown
```{r}
options(width = 1500)
dataM <- matrix(rnorm(100, 5, 2), ncol = 20)
dataM
```
And it works:
I think, that this space under toc is reserved. But can't say it with 100% confidence.
An addition
You should make a custom TOC with CSS.
I'm not a pro with CSS, so, I have compiled something for you. You can modify it...
CSS-file:
#TOC {
font-family: Arial, Helvetica, sans-serif;
color:black;
background-color: white;
position: fixed;
top: 0;
left: 0;
width: 150px;
border: 1px solid Black;
padding: 10px;
margin: 30px;
overflow:auto;
}
body {
max-width: 800px;
margin-left:210px;
line-height: 20px;
}
Your header:
---
title: "R Notebook"
author: "me"
date: "11/10/2021"
output:
html_document:
css: TOC.css
toc: true
---
I have a DT data table in my RMarkdown document that allows users to download to a csv. How can I shift this table to the left in my HTML file
in order to get the whole document to shift left, you can add inline CSS code in your Rmarkdown, like this
---
title: "DT table"
author: "Daniel"
date: "5/22/2021"
output: html_document
---
<style type="text/css">
.main-container {
max-width: 1800px;
margin-left: auto;
margin-right: auto;
}
</style>
```{r, message=FALSE, warning=FALSE}
library(DT)
datatable(iris)
```
Which renders in the web browser all the way to the left.
If you know more CSS than me, then you can control your document with Divs and CSS selectors to get a even more specific layout
I am using the xaringan library from Yihui in R to create a custom template for a presentation.
Part of this is creating custom body slides as pictured below.
I then use custom CSS for the headers and body:
.body-yellow > h2 {
font-size: 42px;
text-transform: uppercase;
padding-left:
}
And then just type in rmarkdown something like:
---
class: body-yellow
# Hello
## world
Hello world
This then populates the slide.
My question is, is there a way to create a placeholder for the image shown in the template above that I could adjust in the rmarkdown code itself?
I am imagining code like:
---
class: body-yellow
background-images: url(./img/my_new_custom_image.png)
# Hello
## world
Hello world
And the relevant adjustment in CSS:
.body-yellow > image {
background-images: PLACEHOLDER
position:right
}
Which will change the image as follows:
Excuse my CSS ignorance, but I am only starting to dabble in this area.
You can set a global background image for the body-yellow class, and override it with the background-image attribute on a particular slide. Here is a minimal example:
---
title: "Test"
output:
xaringan::moon_reader:
nature:
ratio: "16:9"
---
class: body-yellow
```{css, echo=FALSE}
.body-yellow > h2 {
font-size: 42px;
text-transform: uppercase;
padding-left: 50px;
}
.body-yellow {
background-image: url(https://i.stack.imgur.com/OSrg8t.png);
background-size: contain;
}
```
## Default background
---
class: body-yellow
background-image: url(https://i.stack.imgur.com/X1C2Bt.png)
## A custom background
When I create an R Markdown file and knit HTML, the following is present:
<style type="text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
I would like to change the max-width attribute. How would I do that?
Thanks.
There's no way to change that number specifically, but you can override it. Create your own style.css file in the same directory as your document, and give it some content:
body .main-container {
max-width: 500px;
}
Then reference that CSS file in your YAML front matter:
---
...
output:
html_document:
css: style.css
---
If you are only making HTML output you can put
<style>
body .main-container {
max-width: 500px;
}
</style>
at the beginning of the .Rmd file I put mine after the front matter.