我想为以四开本呈现为 HTML 的句子中的单词着色。在 R Markdown 中,我只需添加一个 css 标签,但我不知道如何在四开本中执行此操作。quarto文档说可以编写内联 css,但没有示例。有一个超链接显示了 R Markdown 示例:
```{css, echo=FALSE}
body {
color: red;
}
```
Run Code Online (Sandbox Code Playgroud)
当我这样做时,四开将代码显示为代码块并且不使用 CSS。
如何将 CSS 代码块添加到四开文档?
我想证明文档中文本的合理性Quarto。这意味着它应该自动在单词之间添加文本,以便每行文本的两个边缘都与两个边距对齐。在word-document这将是以下突出显示的符号:
所以我想知道这种方法是否可以在Quarto文档中实现?这是一个可重现的示例:
---
title: "How to justify text in Quarto"
format: html
editor: visual
---
## Quarto
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.
Quarto is based on Pandoc and uses its variation of markdown as its underlying document syntax. Pandoc markdown is an extended and slightly revised version of John Gruber's Markdown syntax.
Markdown is a plain text format …Run Code Online (Sandbox Code Playgroud) 在 quarto Revealjs 中,代码块的字体大小小于文本的字体大小。更改基本字体(使用fontsize)只会按比例更改所有内容。我希望能够调整代码块的相对字体大小。我认为这涉及自定义 CSS,但我不确定要更改什么。
---
format:
revealjs
---
* Here is text
```{r echo=TRUE, eval=FALSE}
str(mtcars)
```
Run Code Online (Sandbox Code Playgroud)
输出如下所示:

更新:修改我提出的问题的答案font-size。code.sourceCode修改font-sizeforcode会更改代码、输出的大小,并且还会更改所有逐字元素的字体大小。不幸的是,对于许多用例来说,它会改变太多。
我必须定期运行两个科目(数学和阅读)的降价报告。目前,我必须在 Markdown 标题、输出文件名(.html 文件)中以及在 R 代码块中设置主题变量以进行数据处理。我想设置一次这个变量并调整标题、输出文件和分析。有没有办法做到这一点?
我知道标题可以通过paramsYAML 标头动态化,但这对输出文件名或 R 代码块内没有帮助。
请参阅下面我当前代码的一部分。请注意,读取变量被指定了 3 次(标题、输出文件名以及“预设”下的 R 代码块内。我想指定一次“读取”(最好在脚本顶部)。
---
title: Reading Investigation"
author: "xxx"
date: "`r format(Sys.time(), '%B %d, %Y')`"
output:
html_document:
code_folding: hide
depth: 3
fig_height: 10
fig_width: 12
highlight: tango
number_sections: no
theme: cerulean
toc: yes
toc_float: yes
knit: (function(inputFile, encoding)
{ rmarkdown::render(inputFile, encoding = encoding,
output_file = paste0('folder/reading_output_', Sys.Date(), '.html') )})
---
```{r, message=FALSE, echo=FALSE, warning=FALSE, results='hide', comment="", fig.height=10, fig.width=12}
# Libraries ------------------------------------------------------------------
library(RODBC)
library(tidyverse)
library(ggplot2)
library(kableExtra)
# …Run Code Online (Sandbox Code Playgroud) 我有一个四开 html 页面,带有侧边栏和目录(即 3 列页面)。我想增加内容列(中心列)的默认宽度,现在固定为 ~950px。我怎么做?
四开.yml
project:
type: website
website:
title: "Big Center Section"
sidebar:
style: "docked"
search: false
contents:
- section: "Sidebar"
contents:
- text: "Item 1"
url: ./somewhere.html
format:
html:
theme:
- flatly
- custom.scss
css: styles.css
toc: true
Run Code Online (Sandbox Code Playgroud)
jupyter ipynb 页面
---
title: "Big wide middle section"
jupyter: python3
format:
html:
code-fold: true
code-line-numbers: true
---
Second cell:
# SOME REALLY REALLY REALLY LONG HEADING I WANT 2000px WIDE.....
Run Code Online (Sandbox Code Playgroud) 我有一个四开 qmd 文件,其中包含以下代码来显示 valueBox。
---
title: "My Dashboard"
output:
flexdashboard::flex_dashboard:
orientation: rows
---
```{r setup, include=FALSE}
library(dygraphs)
library(flexdashboard)
```
### Data
```{r}
valueBox("42", color = "yellow", icon = "fa-calendar", caption = "cases of soda")
```
Run Code Online (Sandbox Code Playgroud)
代码呈现如下,未创建 valueBox。
关于如何像下面在 rmd 文件中那样渲染 valueBox 有什么想法吗?
我有一个 qmd 四开文件,具有不同的输出格式:html 和 pdf。
我的目标是根据输出格式生成图形。
如何在 R 单元中检测处理输出格式是 html 还是 pdf?一个简单的 if 语句就足够了。
---
title: My title
format:
html:
toc: true
toc-depth: 3
html-math-method: katex
pdf:
keep-tex: true
toc: true
number-sections: true
colorlinks: true
---
Run Code Online (Sandbox Code Playgroud) 我正在 R Studio 中使用 Quarto 制作 Revealjs 演示文稿。我正在使用该包{echarts4r}来制作我的绘图。{echarts4r}带有默认动画。当我渲染演示文稿时,所有幻灯片的默认动画已加载。
我想在幻灯片处于活动状态时(即当幻灯片处于视图中时)运行默认的 echarts4r 动画,并在看到其他幻灯片时重置。有人可以帮我解决这个问题吗?
这是四开本演示文稿的代码。
---
title: "A Title"
subtitle: "A Subtitle"
author: "First Last"
institute: "Some Institute"
date: today
self-contained: true
format: revealjs
---
## Introduction
Hello There!
## Pie Chart
```{r}
library(tidyverse)
library(echarts4r)
data <- tibble(name = c("A", "B", "C", "D", "E", "F", "G"),
number = c(9.7, 2.1, 2.1, 1.9, 1.9, 1.9, 80.4))
data %>%
e_charts(name) %>%
e_pie(number, radius = c("50%", "70%")) %>%
e_legend(orient = "vertical", right …Run Code Online (Sandbox Code Playgroud) 如何缩放表格以适应四开 PDF 页面?
例子:
---
title: "Untitled"
format: pdf
---
```{r setup}
#| include: false
library(dplyr)
library(gt)
```
```{r tbl}
#| include: true
#| echo: false
tibble(a = 1000, b = 2000, c = 3000, d = 4000, e = 5000, f = 6000, g = 7000,
h = 8000, i = 9000, j = 10000, k = 11000, l = 12000, m = 13000, n = 14000,
o = 15000, p = 16000, q = 17000, r = 18000, …Run Code Online (Sandbox Code Playgroud) scales::label_percent()在 mutate 函数中使用的语法很不寻常,因为它使用双括号:
label_percent()(an_equation_goes_here)
我认为我以前没有见过()()R 中的语法,而且我不知道如何查找它,因为我不知道它叫什么。我尝试过?`()()`,??`()()`但都没有帮助。双括号语法称为什么?有人可以推荐一个阅读相关内容的地方吗?
这是上下文的示例:
\nlibrary(tidyverse)\nmembers <- \n read_csv(\n paste0(\n "https://raw.githubusercontent.com/rfordatascience/tidytuesday/", \n "master/data/2020/2020-09-22/members.csv"\n ), \n show_col_types = FALSE)\n\n\nmembers %>%\n count(success, died) %>%\n group_by(success) %>%\n # old syntax:\n # mutate(percent = scales::percent(n / sum(n))) \n # new syntax:\n mutate(percent = scales::label_percent()(n / sum(n))) \n#> # A tibble: 4 \xc3\x97 4\n#> # Groups: success [2]\n#> success died n percent\n#> <lgl> <lgl> <int> <chr> \n#> 1 FALSE FALSE 46452 98% …Run Code Online (Sandbox Code Playgroud)