使用R Markdown在HTML演示文稿中进行超链接

问题描述:

我希望我正确地标记了这一点 - 我想在R Studio中使用Markdown创建HTML演示文稿。我想要做的是创建超链接,点击时会跳转到指定页面,而不是大多数演示文稿的直线进度。例如:

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.  

这可能吗?我尝试过搜索,但只能找出如何链接到外部网站(即 [link to google](www.google.com)

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)

尽管结果并不完美,但有可能:

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

[Slide 4](#4)



ioslides默认打开新窗口中的链接,因此这些链接在RStudio预览中不起作用,并且会在运行时创建新的浏览器选项卡。

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.

如果您不关心降价纯度,一个小小的HTML和JavaScript有很长的路要走:

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>