rmarkdown icon indicating copy to clipboard operation
rmarkdown copied to clipboard

TOC get stuck if using lvl below {.tableset} AND TOC-depth on lower lvl than the 'tabs'

Open MrNoClue opened this issue 5 months ago • 0 comments

Tried searching for this issue, but didn't find on the keywords I used, so thought I issue this one.

As the title suggest, introducing {.tabset}, in this case on "#" makes the TOC (I use floating, TOC depth: 3) not register on what heading one are on. If you in my example press a lower header (lvl #) - it gets marked, BUT then the TOC automatically jumps back to first header where {.tabset} appear - although you get to requested section in the html-page. Doing it again (press a lower header lvl), WITHOUT scrolling, let's the TOC stay on the header you suggested - untill you scroll, then it jumps again...

But if you then press a subheading within that, e.g. ## - then the TOC jumps back to the first header where {.tabset} appear again - although, you again, get to the requested section in the html-page.

Summary: using the TOC to navigate works (although not optimal - dubble-click necessary), but it won't stay on active header! EDIT: Using only TOC depth: 2 resolves the issue - so something with using depth 3 on TOC and having specified {.tableset} on #-lvl (first level)? That is, you can't specify TOC-depth deeper than a level you use {.tableset} on? I wanted to do this and manually introduce the {.tableset}-lvls in the TOC (since they don't show, but lover lvl do) with h2. EDIT2: Now I seem to have more clearly nailed down the problem, which is: can't use #-levels below the tab's created with {.tabset}. If you use TOC-depth: 3, some lvl 3 will be shown, if you use ### in chapters w/o {.tabset}, those with {.tabset} you need to remove ### - you can't replace them with "h3" either, cuz the TOC picks up on that and stops working.

Here's my .rmd-file, with just some random text so show you the structure - in my case it always go back to header "# Om".

I don't understand how to input code here, so I link to an example on a thread I started on Stackoverflow: https://stackoverflow.com/questions/77931752/r-markdown-in-r-toc-get-stuck-when-using-tabset-in-headings

CHECKLIST xfun::session_info('rmarkdown') ` R version 4.3.2 (2023-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045), RStudio 2023.9.1.494

Locale: LC_COLLATE=Swedish_Sweden.utf8 LC_CTYPE=Swedish_Sweden.utf8 LC_MONETARY=Swedish_Sweden.utf8 LC_NUMERIC=C
LC_TIME=Swedish_Sweden.utf8

Package version: base64enc_0.1.3 bslib_0.6.1 cachem_1.0.8 cli_3.6.2 digest_0.6.33 ellipsis_0.3.2 evaluate_0.23
fastmap_1.1.1 fontawesome_0.5.2 fs_1.6.3 glue_1.6.2 graphics_4.3.2 grDevices_4.3.2 highr_0.10
htmltools_0.5.7 jquerylib_0.1.4 jsonlite_1.8.8 knitr_1.45 lifecycle_1.0.4 magrittr_2.0.3 memoise_2.0.1
methods_4.3.2 mime_0.12 R6_2.5.1 rappdirs_0.3.3 rlang_1.1.2 rmarkdown_2.25 sass_0.4.8
stats_4.3.2 stringi_1.8.3 stringr_1.5.1 tinytex_0.49 tools_4.3.2 utils_4.3.2 vctrs_0.6.5
xfun_0.41 yaml_2.3.8

Pandoc version: 3.1.1 `

installed and tested your bug with the development version of the rmarkdown package Was not able to do this, since I'm on company computer and lack Administrator rights I presume.

MrNoClue avatar Feb 03 '24 12:02 MrNoClue