A sort-of tutorial
Presentation by James Curley & Matti Vuore / @jalapic / @vuorre
You may or may not be interested to know that this presentation is written in R. Slidify is an R package that compiles R-Markdown scripts into html slideshows. The conversion from R-Markdown to html is done via "frameworks." reveal.js is one such framework.
Matti Vuore and I are trying to put together some sample templates of Slidify to make it easier for others in the Psych department (and the world) to learn.
The code for this presentation can be found here
Each slide will feature some things that can be done in slidify
If you want to recreate the slides you can copy the themes and template from the original code
We're learning too, we have not yet figured out the 'best' way to do things ... in fact some of our methods might look downright bad to accomplished HTML/CSS folks... we're trying though
Thanks for reveal.js to Hakim El Hattab
Thanks for slidify and tutorials to Ramnath Vaidyanathan
Thanks for slidify examples and inspiration to Zev Ross and Kyle Walker
This presentation is still a work in progress. Not all slides are made and some details are missing. We shall continue to update though.
We're also mainly focussed here on the styles and layouts of different slides. We aren't discussing too much how to insert R code and R output into the slides just yet - even though that's maybe the major advantage of slidify.
These are items contained in the YAML. We will describe what the YAML does in more detail later.
--- framework : revealjs revealjs : {theme: moon, transition: none, center: "false"} highlighter : highlight.js hitheme : github widgets : [mathjax] mode : selfcontained url : {lib: ./libraries} knit : slidify::knit2slides ---
revealjs : {theme: moon, transition: none, center: "false"}
Most of the slide style is set by editing the YAML. However, you can also add in some HTML style code underneath your YAML right at the top of your RMarkdown document. This will change the look of all slides in the presentation. Here, we are changing the colors, gap between headers and body text and font type used. (Admission - I'm not sure the 'body' one is working...)
<style> .reveal h4 { color: #00BFFF; padding-bottom: 10px; font-family: 'Helvetica', 'Arial', sans-serif; } .reveal h3 { color: #00BFFF; padding-bottom: 10px; font-family: 'Helvetica', 'Arial', sans-serif; } .reveal h2 { color: #00BFFF; padding-bottom: 10px; font-family: 'Helvetica', 'Arial', sans-serif; } .reveal p { font-family: 'Helvetica', 'Arial', sans-serif; } .reveal body { font-family: 'Helvetica', 'Arial', sans-serif; } </style>
Another option is to use code similar to the previous slide and save it as a CSS file in the folder 'assets/css'. Each custom layout can then be referred back to in RMarkdown. An example would be:
.customstyle1 { margin-top: auto !important; margin-bottom: auto !important; margin-left: auto !important; margin-right: auto !important; color: black; width: 67%; height: 33%; background: #BDB76B; }
By refering to the CSS in assets/css with <div class="customstyle1"> we get the following result:
* in testing this it works locally but not after upload to github?
Probably the quickest and easiest way to change individual features of individual slides is to add little bits of HTML to our RMarkdown code.
The next few slides provide some examples...
With a little bit of HTML, we can do all sorts of things.
roll-in fade-in highlight-red highlight-green highlight-blueCan apply multiple format changes to same piece of text:
I'll fade in, then out
I'll fade in, then go blue, then go green, then go red, then goodbye
It's also possible to make things appear out of sequence on the screen:
This appears last
This appears first
This appears second
* if anyone has a better way of doing this let us know!
You can customize the position, size and color of text quite simply using HTML
You can also make some text bold and other text italicize
Text can be strong or even emphasized though in browsers these look the same as bold and italicized, unless the CSS for each has been adapted.
It might have escaped your notice but this text is marked
All of this is actually very somewhat easy by just adding some HTML tags
I have underlined several words in this sentence also.
Your probably noticed that these lines are smaller than the previous slide - yep, that's done by adding HTML tags too
In fact, all regular HTML tags will work...
Not sure that there would ever be a need for this one
As well as modifying the look of text using RMarkdown and HTML, it's also possible to change things up by adding in a bit of CSS on the fly. As you can see here, the text changes color and gets bolder after adding some CSS inline code.
Now I'm also writing inline CSS text but have added a shadow - why you'd want to is your business.
with a bit of practice
This sentence has a left margin of 30px.
This sentence has a left margin of 100px.
This sentence has a right margin of 100px.
This sentence is left aligned and is purple
This is line one.
Here is another line.
Here is yet another line.
Do you notice the intervals getting bigger?
Even bigger?
This is the biggest gap yet!
I'm a long way away from the others.
This is a really long sentence and we can change the gap between the different lines by simplying adding in a 'line-height' HTML tag
This is a really long sentence and we can change the gap between the different lines by simplying adding in a 'line-height' HTML tag
Your continuous scroll text goes here ... I wonder if this is a good idea or not ?
* This list is a bit different
* Here we've wrapped every line in a 'p align = justify' piece of HTML
* Consequently it has justified the text making it tight from margin to margin but we've lost our bullets - they've been replaced by asteriks.
* You may also notice that the font is different to the body text - tried making them the same, but it's not working ?
You can also write an ordered list using the <ul> tag
I haven't found a good way of making line breaks in a nested list without using HTML tags just yet:
Sometimes you might want to change the types of bullet used:
Above this text is a line that is red and right underneath the header.
Although this is working, I'm not sure if this is the best way to do this as the <hr> tag is not supposed to be used in HTML5
You can do this for each individual slide using HTML if you want to change positioning or size...
This is some text that is going above the columns
You should see two cats
One is black and white and the other one is ginger
Are they friends?
This slide has two columns of unequal widths
- this side is much wider than the picture side of the slide, and takes up far more space
- this is done by saving a default layout in assets/layouts and referring to it at the slide divider
- the width of the picture is 300px
This slide has three columns of equal widths - using a different html layout
(though not sure it's the best solution)
text on the left
text in the middle
text on the right
This slide has three columns of equal widths
Panel is on one side and the text on the other
- Here are some images in a 2x2 panel
- This is done by using a 2 column layout and putting each row of images side-by-side within the same <div>
- Still working on how to adjust the gap between the two rows
Adding in a caption to an image is pretty easy too using the <figure> and <figcaption> HTML tags...
A more simple way may be to use <span class="footnote"> -
Roman Mosaic. Source: wikipedia.com
You may find that this does not work locally but will in a browser...
We've found that you can also use links to mp4 video files using the <video controls> HTML tag...
/video>
Saving the same mp4 video file to the assets/img folder also works using the <video controls> HTML tag...
/video>
"soothe"
"alert"
"mint"
"blackout"
"whiteout"
"sunset"
And finally a custom one in /assets/css/custom.css.