4
votes

I would like to link section headers in a beamer_presentation via Rmarkdown (ie., creating cross-references or Pandoc's internal links). For example, I would like to have a link such as "see 'introduction'", by clicking this link, the presentation should jump to slide with the title 'introduction'.

I have tried this code:

---
output: beamer_presentation
---

## TOC

- [Important](#Important)
- [More](#More)
- [Stuff](#stuff)



## Important

jklödfs

## More


sdfjkls

## stuff {#stuff}

However, the expected behavior does not show up. Instead, if the link is clicked, the first pages is shown (but not the respective slide).


SessionInfo:

pandoc 1.19.1

R version 3.4.0 (2017-04-21) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS Sierra 10.12.5

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached): [1] compiler_3.4.0 backports_1.1.0 magrittr_1.5 rsconnect_0.8 rprojroot_1.2 htmltools_0.3.6 tools_3.4.0 yaml_2.1.14 Rcpp_0.12.11
[10] stringi_1.1.5 rmarkdown_1.5 knitr_1.16 stringr_1.2.0 digest_0.6.12 evaluate_0.10

1
It seems that this question is also addressed here: stackoverflow.com/questions/28264805/…jarauh

1 Answers

-1
votes

Edit:

According to an issue on GitHub:

It seems that slide uses the fragment identifier (the part after the hash in the URL) to keep track of which slide you're on, so all internal links generated by pandoc won't work.

However, yhou can always write your own links liek link where 1 is the slide number you want to link to...

So you have to use the following workaround (in principle same as my old one below, but directly in the Rmd file):

---
title: "Untitled"
author: "John Doe"
date: "13 June 2017"
output:
  slidy_presentation: default
  ioslides_presentation: default
  beamer_presentation: default
---

## TOC

[Important](#(3))

[More](#(4))

[Stuff](#(5))

## Important {#important}

jklödfs

## More {#more}

sdfjkls

## stuff {#stuff}

Old answer below:

I am afraid this is just a workaround, but a working one (at least on my system, Win 8.1, R 3.4.0, pandoc 1.19.2.1, knitr 1.15.16):

Using the Rmd doc below:

---
title: "Untitled"
author: "John Doe"
date: "13 June 2017"
output:
  slidy_presentation: default
  ioslides_presentation: default
  beamer_presentation: default
---

## TOC

[Important](#important)

[More](#more)

[Stuff](#stuff)

## Important {#important}

jklödfs

## More {#more}

sdfjkls

## stuff {#stuff}

Run Knit to html (works for both ioslides and slidy) and find and change the TOC section:

<div id="toc" class="slide section level2">
<h2>TOC</h2>
<p><a href="#important">Important</a></p>
<p><a href="#more">More</a></p>
<p><a href="#stuff">Stuff</a></p>
</div>

to this:

<div id="toc" class="slide section level2">
<h2>TOC</h2>
<p><a href="#(3)">Important</a></p>
<p><a href="#(4)">More</a></p>
<p><a href="#(5)">Stuff</a></p>
</div>

The issue is browser cannot find e.g. the #important section, but finds #(3). I do not know why unfortunately as the produced html file have sections <div id="important" class="slide section level2"> etc.