SmoothSproll没有锚点(Smoothscroll without anchors)
好吧我知道如何平滑滚动到一个锚点,但是每次点击某个对象直到我到达页面末尾时,如何平滑滚动一定的静态量(即300px)。 我可以这样做一次,但一次又一次地怎么做呢?
okay I know how to smooth scroll to an anchor but how do I smooth scroll a certain static amount (ie. 300px) every time I click a certain object until I reach the end of my page. I can do this once but how bout doing it over and over?
原文:https://stackoverflow.com/questions/21975734
最满意答案
所以,这就是我想出来的。 添加绘图钩子,以便在生成块中的小图像之前生成全分辨率的pdf图像:
allow_thumbnails <- function(x, options) { if (!is.null(options$thumb)) { filename <- sprintf("%s.full.pdf", strsplit(basename(x), "\\.")[[1]][1]) absolute_path <- file.path(dirname(x), filename) # generate the full resolution pdf pdf(absolute_path, width = options$thumb$width, height = options$thumb$height) eval(parse(text = options$code)) dev.off() # add an html link to the low resolution png options$fig.link = absolute_path } knitr:::hook_plot_md_base(x, options) }
然后在Rmd文件中,我使用
thumb
参数定义全分辨率图像的大小:```{r init} knit_hooks$set(plot = allow_thumbnails) ``` ```{r my_large_plot, fig.width = 15, fig.height = 15, thumb = list(width = 45, height = 45)} my_large_plot() ```
这会生成一个带有可点击的png的html文件,可将您带到pdf中。
So, this is what I came up with. Add a plot hook, so that you generate a full-resolution pdf image before generating a small image in the chunk:
allow_thumbnails <- function(x, options) { if (!is.null(options$thumb)) { filename <- sprintf("%s.full.pdf", strsplit(basename(x), "\\.")[[1]][1]) absolute_path <- file.path(dirname(x), filename) # generate the full resolution pdf pdf(absolute_path, width = options$thumb$width, height = options$thumb$height) eval(parse(text = options$code)) dev.off() # add an html link to the low resolution png options$fig.link = absolute_path } knitr:::hook_plot_md_base(x, options) }
And then in the Rmd file, I define the size of the full-resolution image using the
thumb
argument:```{r init} knit_hooks$set(plot = allow_thumbnails) ``` ```{r my_large_plot, fig.width = 15, fig.height = 15, thumb = list(width = 45, height = 45)} my_large_plot() ```
This generates an html file with a clickable png that takes you to the pdf.
相关问答
更多-
您可以使用asis引擎来有条件地在knitr中包含/排除任意文本,例如 ```{asis, echo=FALSE} Some arbitrary text. 1. item 2. item Change echo=TRUE or FALSE to display/hide this chunk. ``` 但我刚刚在这个引擎中发现了一个bug并修复了它 。 除非你使用knitr > = 1.11.6,否则你可以自己创建一个简单的asis引擎,例如 ```{r setup, include=FALSE} ...
-
您可以使用乳胶数学模式, knit(text="$100 km^2$",output="test.md") pandoc("test.md", format="latex") 给我: You can use latex math mode for this, knit(text="$100 km^2$",output="test.md") pandoc("test.md", format="latex") gives me:
-
做这个: Report ======================================================== This is my report. Some analysis is included in \href{http://stackoverflow.com/q/16445247/1000343}{LINK TO CHUNK NAMED MY.ANALYSIS HERE} ```{r my.analysis, echo=FALSE} summary(cars) ...
-
现在knitr (自1.3版本)包中包含用于创建表的kable函数: > library(knitr) > kable(head(iris[,1:3]), format = "markdown") | Sepal.Length| Sepal.Width| Petal.Length| |-------------:|------------:|-------------:| | 5,1| 3,5| 1,4| | 4,9| ...
-
使用knitr在R markdown中绘制LaTeX图的标题(Figure caption for LaTeX diagram in R markdown using knitr)[2023-11-25]
因为看起来你已经在你的markdown文件中包含了LaTeX代码,你可以将你的tikz代码包装在一个标准的数字环境中吗? 我相信编号是由LaTeX完成的,而不是编织者,所以knitr不应该知道这是一个数字。 As it looks like you're including LaTeX code in your markdown file already, can you just wrap your tikz code in a standard figure environment? I believe ... -
通过Pandoc通过R中的knitr将Markdown转换为HTML5幻灯片(Converting Markdown to HTML5 slides via Pandoc through knitr in R)[2022-08-24]
首先,将以下内容添加到.Rmd文档中: 然后使用该命令 library(knitr) knit("foo.Rmd") pandoc("foo.md", format="dzslides") 这仍将创建文件foo.html ,但将使用pandoc命令 pandoc -s -S --mathjax -f markdown -t dzslides -o foo.html 'foo.md' 创建它,这将导致输出在HTML5幻灯片中。 Firs ... -
在Markdown / knitr中缩略图的简单方法是什么?(What is a simple way to thumbnail some plots in R Markdown/knitr?)[2023-07-12]
所以,这就是我想出来的。 添加绘图钩子,以便在生成块中的小图像之前生成全分辨率的pdf图像: allow_thumbnails <- function(x, options) { if (!is.null(options$thumb)) { filename <- sprintf("%s.full.pdf", strsplit(basename(x), "\\.")[[1]][1]) absolute_path <- file.path(dirname(x), filename) ... -
read_chunk从r脚本中读取块,因此在read_chunk之前调用read_chunk : <
>= knit_patterns$set(all_patterns[["md"]]) purl("test.Rmd") knit_patterns$set(all_patterns[["rnw"]]) read_chunk("test.R") @ < >= @ read_chunk reads chunks from r script so call purl before read ... -
此问题已在目前Github上的knitr (> = 1.12.6)中修复 。 我正在写出图像的HTML代码,以支持我正在处理的另一个包,我应该只是有条件地启用它。 现在,您应该能够在Markdown输出中看到原始的![]()语法。 This issue has been fixed in knitr (>= 1.12.6) currently on Github. I was writing out the HTML code for images to support another package th ...
-
这似乎有效: --- title: "MWE" output: html_document --- ```{r color, echo = FALSE} options(crayon.enabled = TRUE) knitr::knit_hooks$set(message = function(x, options){ paste0( "
", ansistrings::ansi_to_html(text = x, fullp ...