例如,我希望在 pdf 或 csv 文档的句子中间有一个下载按钮。这意味着句子中应该有一个小按钮,建议您可以下载文档,而不是在导航或侧栏中。这是一些可重现的代码:
---
title: "Download button in text Quarto"
format:
html:
code-fold: true
engine: knitr
---
I would like to have a download button [here]() for pdf or CSV document for example.
Run Code Online (Sandbox Code Playgroud)
我不确定是否可以使用downloadthis包在句子中实现一个干净的按钮,因为它应该位于带有文本的句子的中间。
我正在努力让代码片段在带有四开文件的 vscode 中工作。我已经遵循了所有步骤,但我对此感到困惑。
quarto.json。我的片段如下所示:{
"Create NOTES section and place cursor inside": {
"prefix": "nn",
"body": [
"<!-- BEGIN NOTES -->\n\n$1\n\n<!-- END NOTES -->"
],
"description": "Create Notes section and place cursor inside"
}
}
Run Code Online (Sandbox Code Playgroud)
settings.json文件有以下内容: "[quarto]": {
"editor.quickSuggestions": {
"other": true,
"comments": true,
"strings": true
}
}
Run Code Online (Sandbox Code Playgroud)
但是,在四开文件中,当我按 时,不会出现任何建议nn。
注意,Quarto 文件的扩展名不是.qmd,.Quarto但 vscode 将该文件识别为文件quarto,因为 (i) 这出现在窗口的页脚中.qmd,并且 (ii)quarto.json当我配置用户片段时会自动出现一个文件。
基本上,应该可以将 html 代码直接复制到 Quarto 文档 (.qmd) 中,然后将其呈现到 html 网站。
我尝试这样做,并将以下代码从Simplex 主题复制到四开网站:
<div class="card border-primary mb-3" style="max-width: 20rem;">
<div class="card-header">Header</div>
<div class="card-body">
<h4 class="card-title">Primary card title</h4>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
<div class="card border-secondary mb-3" style="max-width: 20rem;">
<div class="card-header">Header</div>
<div class="card-body">
<h4 class="card-title">Secondary card title</h4>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of …Run Code Online (Sandbox Code Playgroud) 有没有办法在四开图或表格标题中引用参数?在下面的示例中,我可以txt在常规文本块中引用我的输入参数,但不能在图形标题中引用。在图标题中,仅显示原始文本:
---
title: "example"
format: html
params:
txt: "example"
---
## I can reference it in text
Here I can reference an input parameter: `r params$txt`
```{r}
#| label: fig-example
#| fig-cap: "Example: I cannot reference a parameter using `r params$txt` or params$txt."
plot(1:10, 1:10)
```
Run Code Online (Sandbox Code Playgroud) 我有以下四开文档,我想根据 的值执行第二个代码块OK。如下所示,它不起作用。我尝试了两次和三次反引号,仅使用OK,但没有任何效果。我怎样才能做到这一点?
---
title: "Test"
format: html
---
## Set a variable
```{r}
OK <- FALSE
```
## Running Code depending on value of `OK`
```{r}
#| eval: `r OK`
print("OK is TRUE - otherwise you won't see anything here.")
```
Run Code Online (Sandbox Code Playgroud) 我想更改四开版中两列布局的一部分的字体大小。这是一些无需更改字体大小的可重现代码:
---
output: revealjs
---
:::: {.columns}
::: {.column width="40%"}
Example list:
* unordered list
+ sub-item 1
+ sub-item 2
- sub-sub-item 1
:::
::: {.column width="60%"}

:::
::::
Run Code Online (Sandbox Code Playgroud)
输出:
正如你所看到的,这效果很好。两列布局很好。想象一下我想更改文本部分(第一列)的字体大小,我们可以使用style="font-size: 50%;"以下方法来减小字体大小:
:::: {.columns}
::: {.column width="40%" style="font-size: 50%;"}
Example list:
* unordered list
+ sub-item 1
+ sub-item 2
- sub-sub-item 1
:::
::: {.column width="60%"}

:::
::::
Run Code Online (Sandbox Code Playgroud)
输出:
正如你所看到的,字体大小确实减小了,但布局又不一样了。图片向左移动得更多。所以我想知道是否有人知道如何在不移动项目的情况下减小两列布局中列的字体大小?
我正在 RStudio 中使用 Quarto 创建一个图书项目。输出将是 pdf/LaTeX 文件。四开本最初将目录放在标题页之后。但我需要将摘要、前言和致谢放在目录之前。我怎样才能改变这个顺序?是否可以使用_quarto.yml文件更改此序列,还是需要通过LaTeX更改它?
非常方便的方法是迭代变量,然后根据该变量的值动态创建选项卡(此处homeworld)。这与results: asischunk 选项配合得很好。purrr::walk我可以做到这一点,但与 {gt} 包有一些奇怪的交互,因此我只能在使用 时才能使 gt 工作gt::as_raw_html。但是,如果我只在外部生成一个表,purrr::walk则不需要gt::as_raw_html. 这是我收到的错误消息 {gt} 不起作用:
运行过滤器 /Applications/quarto/share/filters/quarto-pre/quarto-pre.lua 时出错:...lications/quarto/share/filters/quarto-pre/quarto-pre.lua:2410:尝试连接 nil值(本地“v”)堆栈回溯:...lications/quarto/share/filters/quarto-pre/quarto-pre.lua:2417:在函数 <...lications/quarto/share/filters/quarto-pre /quarto-pre.lua:2415>
这是要重现的四开本(四开本版本 1.1.175)代码:
---
title: "Untitled"
format: html
execute:
warning: false
---
```{r r-pkgs}
library(dplyr)
library(glue)
library(gt)
library(purrr)
## just to simplify
starwars <- starwars %>%
filter(!is.na(sex))
```
# Does work
::: {.panel-tabset}
```{r}
#| results: asis
walk(
unique(starwars$sex), \(hw) {
cat(glue("## {hw} \n\n"))
starwars %>%
filter(sex == hw) %>%
count(homeworld) %>% …Run Code Online (Sandbox Code Playgroud) 我正在编写一份简短的四开本文档,其中解释了一些 SQL 子句/关键字。我希望在我的代码块中突出显示所有这些子句,但默认语法突出显示并不支持所有这些子句。有没有办法将自定义关键字添加到语法突出显示设置中?
例如,我编写了以下代码块:
SELECT col_name(s)
FROM tbl_name
LIMIT n OFFSET m
-- Syntax supported by MySQL, MariaDB, PostgreSQL, SQLite
-- LIMIT = number of rows to retrieve
-- OFFSET = starting row (optional)
Run Code Online (Sandbox Code Playgroud)
SELECT TOP n col_name(s)
FROM tbl_name
-- Syntax supported by SQL Server and MS Access
Run Code Online (Sandbox Code Playgroud)
我在渲染的文档中得到以下输出:
我希望 和 都OFFSET以TOP橙色突出显示,例如等SELECT。FROM我该怎么做?
显示四开文档参考文献的默认方式似乎采用以下格式放置作者姓名:Last1, First1, First2 Last2, First3 Last3, and First4 Last4。因此,第一作者姓名的显示方式与其他作者姓名不同。这是故意的吗?有办法改变吗?
这是一个例子:
\n---\nproject:\n type: website\nformat: html\nbibliography: references.bib\n---\n\n## Text\n\n@bibitem1\nRun Code Online (Sandbox Code Playgroud)\n内容references.bib
@article{bibitem1,\n author = {First1 Last1 and First2 Last2 and First3 Last3 and First4 Last4},\n title = {Article title},\n journal = {Journal name},\n year = {2013},\n volume = {3},\n number = {72},\n pages = {14--18}\n}\nRun Code Online (Sandbox Code Playgroud)\n显示为
\nLast1, First1, First2 Last2, First3 Last3, and First4 Last4. 2013. \xe2\x80\x9cArticle Title.\xe2\x80\x9d Journal Name 3 (72): 14\xe2\x80\x9318. \nRun Code Online (Sandbox Code Playgroud)\n 我想在 pdf 中的特定页面之后添加空白页面Quarto。我尝试使用这里\newpage描述的方法和这个可重现的示例:
---
title: "Add blank page after certain page"
format: pdf
---
# Chapter 1
Here some random text
\newpage
\newpage
# Chapter 2
Again random rext after white page
Run Code Online (Sandbox Code Playgroud)
输出:
正如您在输出中看到的,第一页之后没有空白页。我也\pagebreak像这里一样尝试过,但这也行不通。所以我想知道是否有人知道如何在 pdf 四开的两章之间添加空白页?