I have the following code in an rmd
file which leverages tikz
for diagrams:
---
title: "TestNonTufteLua"
author: "Me"
output:
pdf_document :
latex_engine: lualatex
---
Prove tikz works:
```{r tikTest1, engine = "tikz"}
usetikzlibrary{shapes}
egin{tikzpicture}
ode[ellipse, draw=black, align = center] (Data) {Data $y_{n}$};
end{tikzpicture}
```
Then, when you set `eval = TRUE` in the below code, it will not work.
```{r tikTest2, eval = FALSE, engine = "tikz"}
usetikzlibrary{graphs, graphdrawing}
usegdlibrary{layered}
ikz [gr/.style={gray!50}, font=fseries]
graph [layered layout] {
% A and F are horizontally aligned if you also set weight=0.5 for A -- C.
A -- [minimum layers=2] C -- F,
{ [nodes=gr, edges=gr] A -- B -- { E, D -- F } }
};
```
When changing to eval=TRUE
in the second chunk, I get the following
error:
Quitting from lines 24-29 (testNonTufteLua.Rmd) Error: running
'texi2dvi' on '.ikz36747a021b22.tex' failed
LaTeX errors: rarygraphdrawing.code.tex:22: Package pgf Error: You
need to run LuaTeX to use the graph drawing library.
This error occurs when using the knit
button from RStudio or using render("testNonTufteLua.Rmd", output_format = pdf_document(keep_tex = TRUE, latex_engine = "lualatex")
. I have also experimented with setting options(tikzDefaultEngine = "luatex")
to get tikzDevice
to handle it properly, but it still does not work. I just can't seem to get the graphdrawing
library to work even though the tikz-shapes
library can be loaded and also that the rest of the document seems to be compiled with lualatex
. Thanks for any help!!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…