Using tikz graphdrawing library within RMarkdown … Need to use lualatex engine, but can't get it to work

前端 未结 2 1737
醉梦人生
醉梦人生 2020-12-22 01:50

I have the following code in an rmd file which leverages tikz for diagrams:

---
title: \"TestNonTufteLua\"
author: \"Me\"
output:
          


        
2条回答
  •  Happy的楠姐
    2020-12-22 02:33

    A small running variation of the example above is the following using tinytex.

        ---
        title: "lualatex. Using `tinytex.engine`"
        output:
          html_document:
            df_print: paged
          pdf_document:
            latex_engine: lualatex
        ---
    
       ## Latex engines
       By default, PDF documents are rendered using `pdflatex`. You can specify an
       alternate engine using the `latex_engine` option. Available engines 
       are `pdflatex`, `xelatex`, and `lualatex.` 
    
        ```{r setup}
        options(tinytex.engine = "lualatex")
        ```
    
        ```{r tikzLua, eval = TRUE, engine = "tikz", engine.opts = list(template =  "tikz2pdf.tex")}
        \usetikzlibrary{graphs, graphdrawing}
        \usegdlibrary{layered}
    
       \tikz [gr/.style={gray!50}, font=\bfseries]
       \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 } }
        };
        ```
    

    After an update in knitr the example above stopped running.

提交回复
热议问题