search

Home  >  Q&A  >  body text

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

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

The standard method is:

---
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 tab set:

---
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 tab sets, or how to create internal links/anchors, but intersection: how to create internal links to tabbed sections. The output should look like this:

I've tried some alternative anchoring methods (such as naming the section to link to and using that name in the link). But there is no joy. The link is highlighted in the output, indicating that it should work, but when clicked it does not.

I haven't found anything that says you can't link tabbed sections, so I'm asking here if there is a way, or if there just isn't a way.

Thanks!

P粉541551230P粉541551230344 days ago510

reply all(2)I'll reply

  • P粉277464743

    P粉2774647432023-12-21 17:18:15

    I just followed this answer. If you want to link a larger section (Section) you can use: #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 to the subsection, as you mentioned, you would use: [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

    reply
    0
  • P粉006847750

    P粉0068477502023-12-21 14:53:18

    This appears to be a bug marked as unfixable. Not supported by design, see issue on GitHub.

    reply
    0
  • Cancelreply