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

时间:2014-11-07 18:13:58

标签: html markdown rstudio knitr

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

---
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)

2 个答案:

答案 0 :(得分:8)

虽然结果并不完美,但这是可能的:

[Slide 4](#4)

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

如果你不关心降价纯度会更容易 - 一点点HTML和JavaScript都有很长的路要走:

<a href="javascript:slidedeck.loadSlide(4)">Slide 4</a>

答案 1 :(得分:1)

R Markdown制作的幻灯片可以按标题显示;这应该有效:

## 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