Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I add a "go to top" button to an HTML document rendered in R Markdown?

Sometimes I create long HTML reports and it's difficult to tell other people where to look at during a conference call as there's no page reference. I would like to add a "go to top" button that will hold its place when scrolling the page. This way, after discussing one section of results, I can instruct other team members to click on that button, and go back to the top of the document where the table of contents is and we go from there.

Even better, is it possible to add field with a drop-down list of links to section and subsection titles?

like image 838
user52725 Avatar asked Apr 09 '15 14:04

user52725


2 Answers

It's actually really easy. Simply insert this line of code at the end of your document (or wherever you want to put it):

 <a href="#top">Back to top</a>

This should do the trick. Atleast it works with html markdown documents made with knitR.

If you want to create a drop down element, you have to look into html forms and select option.

like image 156
maRtin Avatar answered Oct 04 '22 09:10

maRtin


This is a bit dated but I was looking for this today.

I ended up adding this at the end of my mark down pages.

[Back to top](#) // any text here would work unless you want to point to a particular id in the html

And it seems to work fine too. I mean it will be converted to the same html as the above but at least you can use the md syntax

like image 40
daniele bertella Avatar answered Oct 04 '22 09:10

daniele bertella