html - 如何在 R Markdown 中设置上一个/下一个按钮
问题描述
我能够使用 R markdown 成功设置目录。但是无法找到提供按钮以导航到上一页/下一页的方法。我希望它类似于此页面:https ://bookdown.org/yihui/rmarkdown/rmarkdown-site.html#site_navigation
我开始按照 rmarkdown 书的解释介绍一个目录。 https://bookdown.org/yihui/rmarkdown/pdf-document.html#table-of-contents-1 以下是我相应使用的 YAML 设置:
标题:“摘要报告”输出:html_document:toc:true toc_depth:2 number_sections:true df_print:分页toc_float:collapsed:true smooth_scroll:true
但是,这仍然不像原始链接中那样提供上一个/下一个按钮。想知道我是否缺少可以启用此功能的选项?
解决方案
以下是如何使用 HTML 在 R Markdown 中设置上一个/下一个按钮。
在我的示例中,我创建了四个标题:“上一个/下一个按钮”、“渲染文档”、“查找每个页面的参考”和“添加按钮”。它们将像这样链接:
我测试的第一页:href="#previousnext-button"
第二页:href="#render-document"
第三:href="#look-for-the-reference-for-each-page"
第四:href="#add-the-buttons"
它们以井号标签开头,后跟标题名称(井号标签和标题标题之间没有空格)。标题必须小写,用破折号连接,如下所示: "#the-name-of-the-heading-in-lowercase-separated-by-dashes
. 如果标题中有斜杠,请忽略它,并将由斜杠分隔的两个单词键入为 one。
按钮的一个示例如下所示:
<ul class="pager"> <!--this is the style of the button-->
<li><a href="#">Back to Summary</a></li> <!--This button takes me to the table of contents-->
<li><a href="#render-document">Next</a></li> <!--This button takes me to the previous page-->
</ul>
ul class="pager"
这是按钮的样式。
href="#Your-heading-reference"
将带您到链接的标题。
href="#"
将带您回到目录。
这是我的测试图像:
推荐阅读
- angular - Angular 8:POST http://localhost:4200/assets/data/students.json 404(未找到)
- postgresql - PostgreSQL - 比较 ts_vector 字段
- database - 如何使用 axios 从数据库中获取数据
- asp.net-core - 从 ASP.NET Core 项目发布单页
- javascript - 根据 ReactJs 中的请求获取数据
- pandas - 时间计算熊猫
- jqgrid - Jqgrid 内联编辑提交 html 而不是键入的文本
- r - 从 R 降价创建多个报告时出错 - 名称不同但数据相同
- vba - ms word文档文本翻译使用vba代码
- reactjs - 指定不带字段名称的 JSON 值