本文介绍了输出格式为 PDF/LaTex 的 Rmarkdown 文件中的 DiagrammeR/mermaid 流程图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在用 R markdown 生成的 PDF 中包含美人鱼图.
I would like to include a mermaid diagram in a PDF generated with R markdown.
根据这篇文章,美人鱼创建一个 HTML 小部件作为输出.不幸的是,为 xaringan 幻灯片提供的答案不适用于 R markdown 中生成的 PDF.
According to this post, mermaid creates an HTML widget as output.Unfortunately, the answer provided there for xaringan slides does not work for PDFs generated in R markdown.
下面是 Rmd-MWE.任何帮助是极大的赞赏!
A Rmd-MWE is below. Any help is greatly appreciated!
---
title: "DiagrammeR: mermaid diagram in Rmd"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Simple mermaid diagram
```{r}
library(DiagrammeR)
mermaid("
graph LR
A-->B
", height = '100%', width = '100%')
```
推荐答案
在 Rstudio 控制台中运行这两行:
Run these two lines in your Rstudio console:
install.packages('webshot')
webshot::install_phantomjs()
https://bookdown.org/yihui/bookdown/html-widgets.html
这篇关于输出格式为 PDF/LaTex 的 Rmarkdown 文件中的 DiagrammeR/mermaid 流程图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!