文档顶部的 R Markdown 锚点 [英] R markdown anchor at the top of document
问题描述
类似于在此处我试图在长文档中插入锚点的问题用户可以轻松导航到文档的 TOC.
我的代码如下:
---标题:示例文件"输出:html_document:目录:真实主题:团结---<a id="顶部"></a># 第一部分
然后我添加 [Go to Top](#top)
任何我想要链接到文档顶部的地方.
我遇到的问题是,在单击 Go to Top
时,页面会向上滚动,使得 First Section
位于顶部,而不是目录(是我想要的).所以用户必须再次向上滚动才能转到目录.
有什么办法可以滚动回文档的最顶部,以便在页面上再次看到 TOC.
我试图将 <a id="top"></a>
放在 ---
之前,但这不起作用.>
任何帮助将不胜感激!!谢谢.
只需在某处添加您的链接并引用 #header
...
返回顶部</a>
Similar to the question asked here I am trying to insert anchors in a long document so that users can easily navigate to the TOC of the document.
My code is as follows:
---
title: "Sample Document"
output:
html_document:
toc: true
theme: united
---
<a id="top"></a>
# First Section
Then I add [Go to Top](#top)
wherever I want a link to go to the top of the document.
The problem I am having is that on clicking Go to Top
, the page scrolls up such that First Section
is at the top, not the Table of Contents (which is what I want). So the users have to scroll up again to go to TOC.
Is there any way to scroll back to the very top of the document, so that TOC is seen again on the page.
I tried to to put <a id="top"></a>
before ---
, but that does not work.
Any help would be much appreciated!! Thanks.
Just add you link somewhere and refers to #header
...
<a href="#header">back to top</a>
这篇关于文档顶部的 R Markdown 锚点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!