Quarto/Rmarkdown中的美人鱼图表:狭窄且模糊。

3
我正在尝试生成pdf格式的夸尔托文档(稍后还有word格式)。我遇到了mermaid图表的问题。 请看下面附上示例.qmd文件以说明问题。
首先,它应该支持{mermaid}标记,但是当我这样做时,在rstudio中无法“运行”单元格,而且我的文档实际上也没有生成。在rstudio中,“后台任务”一直卡在“输出文件:testmermaid.knit.md”。
所以我使用DiagrammeR::mermaid来封装它,然后文档确实生成了,但大小太小,如果我调整生成的图形大小,则变得模糊不清。我进行了多次尝试,但都没有成功,所以如果有人能提供一个简单的解决方案,其中图表会从左边Xcm到右边Ycm,并在pdf和word中正确生成?
编辑:

在@Shafee的评论之后,我注意到我没有安装quarto包,现在我已经安装了最新的R package quarto 1.0.36并重新安装了RStudio (2022.07.1 build 554),但问题仍然存在。
我还注意到我的个人电脑(相同版本的RStudio和quarto)没有这些问题(虽然在Rstudio IDE中仍然无法运行mermaid块)。

编辑2:

在本地硬盘上进行完整重新安装(而不是Windows网络驱动器),我得到了以下结果:
output file: testmermaid.knit.md
ERROR: 找不到打开的服务器

我的版本现在是:

quarto::quarto_version() 1 ‘1.1.189’

mermaid diagram narrow

---
title: "TestMermaid"
format: pdf
---

```{r libimport}
library(quarto)
library(DiagrammeR)
knitr::opts_chunk$set(echo = F)
```


## Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.


Attempt #1

```{mermaid attempt1}
flowchart LR
  A[Hard edge] --> B(Round edge)
  B --> C{Decision}
  C --> D[Result one]
  C --> E[Result two]
```

Attempt #2

```{r attempt2}
mermaid("
sequenceDiagram
  participant ParticipantA
  participant ParticipantB
  participant ParticipantC
  ParticipantA->>ParticipantB: I want something
  ParticipantB->>ParticipantC: he want something
  ParticipantC->>ParticipantB: here is something
  ParticipantB->>ParticipantA: he got something for you
  ", height = '100%', width = '100%')
```

这两种尝试对我来说都很好用。你的 Quarto 版本是多少?(我正在使用版本“1.0.38”) - shafee
你好,Shafee,感谢你的建议。我正在将细节添加到原始帖子中,因为它太长了,无法在评论中解决这个问题 :( - Will
好的,在你的情况下,你不需要调用 {quarto} r 包。另外,你能否添加 quarto 版本(不是 {quarto} r 包的版本,我指的是 quarto CLI 的版本)。要检查 quarto 的版本,可以运行 quarto::quarto_version() - shafee
我提到的1.0.36版本是quarto::quarto_version()的输出。现在我已经安装了quarto CLI版本v 1.1.189,quarto::quarto_version()的输出仍然是1.0.36,但当我渲染时,我现在看到:输出文件:testmermaid.knit.md错误:找不到打开的服务器。 - Will
如上所述,我实际上已经重新安装了RStudio(因此在重新安装之前关闭了应用程序)。无论如何,我已经重新启动并收到了一个额外的错误消息,抱怨:Check file:///C:/[...]/puppeteer@9-0-2/mod.ts 错误:找不到打开服务器。现在,我已经将quarto重新安装到本地驱动器而不是网络驱动器中,创建了一个清晰的quarto项目,并重复使用了相同的引用代码。现在,如果我运行quarto::quarto_version(),我确实得到“1.1.189”,但渲染仍然无法工作:“输出文件:testmermaid.knit.md 错误:找不到打开服务器”。 - Will
1
同样的问题在这里。我找不到解决方案。 - Cmagelssen
1个回答

0

如果从第7行中删除library(quarto)调用,则您的代码将按预期执行。

根据Quarto图表的文档,可以通过使用块选项来增加大小。

```{mermaid attempt1}
%%| fig-width: 6.5
%%| fig-cap: Fig 1. Test figure
flowchart LR
  A[Hard edge] --> B(Round edge)
  B --> C{Decision}
  C --> D[Result one]
  C --> E[Result two]
```

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接