TOC problem when knitting Rmarkdown document with images

511 Views Asked by At

Finished and published on github my first website using Distill package in RStudio: https://crlnp.github.io/3-objets.html

On this particular page I include several images in my rmarkdown document and it causes problems with the table of contents: the headings are duplicated and don't follow the headings adequatly. I have tried every toc_float: option available and it does not solve the problem. Aldo tried changing the heading levels (all #, ...). The problem appears wether the image is inserted traditionally or in a code bloc. If I take out the images in my file, the TOC works perfectly. I have not been able to find any information on this issue. Thanks in advance for any help!

1

There are 1 best solutions below

2
On

Your .Rmd file on the website (GitHub) repo.
If you include JS file (optional) and move wrapping div container, from current position to above your first header, TOC behaviour will change:

<script src="hideOutput.js"></script>
<div class="fold o">
## 1. Les objets
.
.
.
</div>

Is this helpful in any way?

Output:
enter image description here