4

I hope I've tagged this correctly - I'd like to create an HTML presentation using Markdown in R Studio. What I'd like to do is to create hyperlinks that will jump to a specified page when clicked versus the straight linear progression of most presentations. For example:

---
title: "Presentation"
output: ioslides_presentation
---

## Slide 1

This is the first slide. I'd like to be able to insert hyperlinks to a different page within the slide. For example:

[Slide 2](hyperlink to slide 2) - clicking this would jump to slide 2

[Slide 3](hyperlink to slide 3) - clicking this would jump to slide 3

[Slide 4](hyperlink to slide 4) - clicking this would jump to slide 4

## Slide 2

Text for slide 2

## Slide 3

More text for slide 3

## Slide 4

Even more text for slide 4.  

Is this possible? I've tried searching around but can only find out how to link to external sites (i.e. [link to google](www.google.com)

GregRousell
  • 997
  • 2
  • 13
  • 23

2 Answers2

9

It's possible, although the result isn't perfect:

[Slide 4](#4)

ioslides opens links in new windows by default, so the links won't work in the RStudio preview, and will create new browser tabs at runtime.

It's much easier if you don't care about markdown purity--a little HTML and JavaScript go a long way:

<a href="javascript:slidedeck.loadSlide(4)">Slide 4</a>
Jonathan
  • 8,497
  • 41
  • 35
  • Thanks, I got that to work but I was hoping to keep it all in the same tab. I'll keep fiddling with it and see what I can figure out. – GregRousell Nov 10 '14 at 13:27
  • I forgot that Pandoc doesn't strip Javascript URIs--try updated answer :-) – Jonathan Nov 10 '14 at 22:12
  • Initially, this didn't work for me (at least in default firefox, and edge browser). It required to add the argument: target="_self". See also: https://stackoverflow.com/questions/44884990/opening-a-link-in-the-same-tab-with-html – user3283722 Jul 07 '21 at 12:54
0

R Markdown produces slides which can be href'd by title; this should work:

## Slide 1

This is the first slide. I'd like to be able to insert hyperlinks to
a different page within the slide. For example:

[Slide 2](#/my-second-slide) - clicking this would jump to slide 2

[Slide 3](#/my-third-slide) - clicking this would jump to slide 3

## My second slide

Text for slide 2

## My third slide
Peter Straka
  • 141
  • 1
  • 8