r - 可以从文档开头以外的任何地方预览 R Markdown 吗?
问题描述
我目前正在用 R Markdown 写一些东西。每当我编写文档时,RStudio 的预览都会将我带回到文档的开头。有没有办法让这个新的预览显示一个更接近我默认工作的位置?例如,我可以在我的打字光标附近的位置进行预览吗?
评论提出了一些解决方法。到目前为止,我最好在 RStudio 的预览窗口提供的搜索栏中输入我正在工作的部分的部分编号。我会单击目录中的相关条目,但我使用output: github_document: toc: true number_sections: true
的是 ,它正在等待其编号目录的补丁。
解决方案
不像您想象的那么简单,但是可以使用 javascript 来控制显示 html 文档的哪个部分:
---
title: "Untitled"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
```{js}
location.hash = "#goto";
```
```{r, results='asis'}
cat(sprintf("# %s\n\nSection text here.\n\n", 1:10), sep = "")
```
# GOTO
Scroll Here
```{r, results='asis'}
cat(sprintf("# %s\n\nSection text here.\n\n", 11:20), sep = "")
```
推荐阅读
- google-data-studio - 有没有办法在没有刷新报告的情况下在 Google Data Studio 中每分钟动态显示日期时间?
- javascript - 使用服务器端 Asp 项填充 SweetAlert2 Html 选择输入项
- python - 子进程未创建 ffmpeg 命令的输出文件
- android - 如何解决 Android 上的这个 adb 授予权限错误?
- html - svg上的渐变
元素不工作 - python - python 正在显示在 Windows 中键入 python -v 时要安装的东西的列表
- ios - 快速比较发布时间和当前时间
- msal - MSAL - 刷新令牌到期日期
- google-sheets - 如何避免使用公式或动态数据重写谷歌表格单元格?
- protocols - 如何确定 KNX 设备是否能够发送扩展帧?