我目前正在尝试通过 rstudio 平台从 rmarkdown 迁移到 quarto。第一步,我想基于 elsevier 模板创建一篇科学文章,可以在Text中找到。然而我却未能复制它。当我尝试渲染时,template.qmd突然出现一个警告信号ERROR: No valid input files passed to render。
我查看了格式,奇怪的是,如果我向其中添加附加行,它会以某种方式起作用。
原始代码(不工作):
---
title: Short Paper
author:
- name: Alice Anonymous
email: alice@example.com
affiliations:
- id: some-tech
name: Some Institute of Technology
department: Department Name
address: Street Address
city: City
state: State
postal-code: Postal Code
attributes:
corresponding: true
note: This is the first author footnote.
- name: Bob Security
email: bob@example.com
affiliations:
- id: another-u
name: Another University
department: …Run Code Online (Sandbox Code Playgroud) 我正在尝试 Quarto,我使用的是 R 版本 4.2.1。当我转到 RStudio、文件 -> 新文件 -> 四开文档并创建一个新文档时,当我尝试通过 RStudio 渲染按钮进行渲染时,出现错误“C:/Program”未被识别为内部或外部命令、可运行的程序或批处理文件
我尝试将 R 安装在安装路径中没有空格的目录中,但这并没有解决问题。
更新:quarto check按照评论中的建议进行操作
不知道这意味着什么,但我能够通过确保我的qmd四开文件名称中没有空格(用下划线替换空格)来解决问题。然后错误就消失了。
我一直Quarto在 RStudio 中做一些演示。
我喜欢用 来进行演示revealjs,而不是将输出转换.html为.pdf发送给我的学生。
我可以同时渲染两种格式吗?
---
title: "R and RStudio"
author: "RTheodoro"
institute: "USP"
format:
revealjs:
logo: img/usp_logo.png
slide-number: true
show-slide-number: all
preview-links: auto
width: 1280
height: 720
theme: default
editor: visual
execute:
echo: true
---
## What is R?
- R is.....
Run Code Online (Sandbox Code Playgroud) 这有点复杂,但我认为其他人也可能遇到这个问题。
\nQuarto 很棒,但遇到了一个问题,即一个函数 ( quarto_render) 无法在通过 .bat / .cmd 文件访问的脚本中呈现文档。如果我从 RStudio IDE 运行 R 脚本,没有问题,但通过 .bat 访问,是的。已经能够重现该问题,我将尝试概述该问题并希望有人能够提供解决方法。
不幸的是,重新创建需要一些时间,因为需要三个文件(我正在处理的实际项目使用五个单独的文件)。我正在使用的源项目文件夹名为 Test,直到文件 3 为止它才真正发挥作用。
\n文件 1 - test_document.qmd
\n创建一个新的 .qmd 文档(我称之为我的test_document.qmd)。设置为 html 输出,并保留默认的 YAML 和其他文本。无需修改。
文件 2 - test_script.R
\n创建一个新脚本 ( test_script.R)。通过以下方式...
library(quarto)\nlibrary(here)\n\nquarto_render(here("test_document.qmd"))\nRun Code Online (Sandbox Code Playgroud)\n运行时,这应该将 Test_document.qmd 呈现为文件位置中的单独 html 文件。
\n文件 3 - test.cmd - (这是开始出现问题的地方)
\n当扩展名更改为 .bat 时,文本文件 (.txt) 应在命令提示符中呈现。.cmd 文件中使用的代码附在下面,但必须编辑部分,因为它是基于工作的。
\n文件夹开始位置为“C:\\Temp\\Test”
\n{.cmd file}\ncd /d %~dp0 \nif exist …Run Code Online (Sandbox Code Playgroud) 渲染时如何自定义 r quarto pdf 文档的文件名?之前,当我使用 Rmarkdown 时,我在 YAML 中使用以下代码:
---
title: "Some title"
author: "First Last"
date: "`r format(Sys.Date(), '%d %B, %Y')`"
output: pdf_document
knit: (function(inputFile, encoding) { rmarkdown::render(inputFile, encoding = encoding, output_file = file.path(dirname(inputFile), paste0(Sys.Date(),"_Report","_FirstLast",".pdf"))) })
---
Run Code Online (Sandbox Code Playgroud)
当我点击“Knit”按钮时,pdf 文档的文件名将是 2022-08-08_Report_FirstLast.pdf
有没有办法用 quarto pdf 做到这一点?我认为需要使用quarto_render函数但不知道如何使用。
我正在尝试使用新的 Quarto 生成的 HTML 文件而不是旧的 RMarkdown 生成的 HTML 文件来更新我的作品集网站。我已经渲染了这些更新的文件,它们看起来很棒!
然而,当我使用 htmlpreview 将此 HTML 上传到我的 GitHub Pages 网站时,我得到了一张非常不同的图片......
请记住,htmlpreview 对于我的 RMarkdown 渲染文档效果非常好:
这是我的 Quarto 文档的 YAML(如果有帮助的话):
author: "Brian Lookabaugh"
toc: true
number-sections: true
format:
html:
code-background: true
Run Code Online (Sandbox Code Playgroud) 有没有办法在输出中包含块选项?
例如,在这种情况下:
---
title: "Untitled"
format: html
editor: visual
---
```{r}
#| code-fold: true
#| label: example
1 + 1
```
Run Code Online (Sandbox Code Playgroud)
如何获得
#| code-fold: true
#| label: example
Run Code Online (Sandbox Code Playgroud)
在输出中(在实际使用的之上)?
当 RMarkdown.rmd文档被编织为 PDF 时,文本正文以及标题、副标题和标题都以相同的 LaTeX 标准字体呈现。
将四开.qmd文档渲染为 PDF 时,文本正文的字体保持不变,但标题、副标题和标题以不同的字体渲染,没有衬线。
为了实现较旧的 R Markdown 文档和较新的 Quarto 文档的输出之间的一致性,我想将标题、副标题和标题的字体更改回正常字体。我怎样才能实现这个目标?
我尝试fontfamily:在 YAML 标头中使用,但这没有找到我想要的字体。\setkomafont{section}{\normalfont}我通过使用in取得了一些成功include-in-header:,因为这确实改变了字体,但仅限于 h1 标题,而不是 h2 或标题或副标题。它还删除了 h1 的所有其他格式(例如字体大小、粗体等),这不是我想要的。
我正在尝试在 RStudio 中创建一本四开本书籍。当我在 YAML 中添加日期格式时,无法呈现该书。当我删除日期格式字段时,我可以成功渲染它。示例 YAML 规范(在_quarto.yml项目文件中)如下:
project:
type: book
book:
title: "A Sample Book Title"
author:
- name: "Eva"
date: today
#date-format: "MMM D, YYYY"
page-footer:
border: true
chapters:
- index.qmd
- intro.qmd
- summary.qmd
- references.qmd
bibliography: references.bib
nocite: |
@*
format:
html:
theme: cosmo
pdf:
documentclass: scrreprt
fig-align: center
fig-width: 6
fig-height: 5
fig-pos: 'h'
fig-cap-location: bottom
tbl-cap-location: top
pdf-engine: lualatex
keep-tex: true
linestretch: 1.5
toc: true
toc-depth: 2
toc-title: Contents
lof: true
lot: true …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种通用方法来自动将 ggplot 的字体与 html 主题使用的字体进行匹配。在下面的代码中,我想检测“yeti”主题使用“Open Sans”字体作为正文。同样,如果主题是“united”,则应该检测到字体是“Ubuntu”。
---
title: "Untitled"
output:
html_document:
theme: yeti
date: "2022-09-14"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(dev = "ragg_png") # so that fonts render effortlessly
```
```{r plot}
library(ggplot2)
font <- magic_function_to_retrieve_current_font()
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme_gray(base_family = font)
```
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,我想知道一个函数,这里称为magic_function_to_retrieve_current_font(),它执行以下操作:
现在(3)和(4)我可能自己弄清楚了,但我在步骤(1)和(2)上遇到了困难。是否有一些神奇的 knitr/rmarkdown/quarto 函数可以用来在编织文档时访问 YAML/主题样式表?