Is there a way to link to a tabbed section in rmarkdown?

Viewed 682

I would like to create an internal link to a section in my rmarkdown document, but the section is a tab, and the standard linking approach doesn't seem to work.

Standard approach would be:

---
title: "Untitled"
output: html_document
---

# Section to link to

text and more 

# Next section

See [this section](#section-to-link-to)

Works!

In my case the section I want to link to is part of a tabset:

---
title: "Untitled"
output: html_document
---

# Section {.tabset}

## Subsection to link to

text and more 

## Next subsection

text and more

# Next section

See [this section](#subsection-to-link-to)

Doesn't work :(

EDIT: to be clear -- my question is not how to create a tabset, or how to create an internal link/anchor, it's the intersection: how to create an internal link to a tabbed section. The output should look like this:

tab section with link

I've tried some of the alternative anchor approaches (like naming the section to link to, and using that name in the link). But no joy. The link is highlighted in the output, suggesting it should work, but it doesn't work when clicked.

I haven't found anything that says you can't link a tabbed section, so I'm asking here to see if there's way, or just no way.

thx!

2 Answers

I just followed this answer. If you want to link the bigger section (Section), you could use this: #section.

Code:

---
title: "Untitled"
output: html_document
---

# Section {.tabset}

## Subsection to link to

text and more 

## Next subsection

text and more

# Next section

See [this section](#section)

This seems to work

To link the subsection, as you mentioned, you could use this: [this section](#subsection-to-link-to).

Code:

---
title: "Untitled"
output: html_document
---

# Section {.tabset}

## Subsection to link to

text and more 

## Next subsection

text and more

# Next section

See [this section](#subsection-to-link-to)

This seems to work

This appears to a bug that's labelled as won't fix. Not supported by design, please see the issue on GitHub.

Related