I am using latest version of blogdown
and tinytex
to render a page containing this snippet:
The following diagram:
```{r, echo=FALSE, engine='tikz', fig.cap='This is it.', engine.opts = list(template = "../latex/header.tex")}
\begin{tikzpicture}[scale=.7, remember picture]
\tikzmath{ \w = 6; \h =4; \x = 2; \y = 1; }
\draw [fill=gray!30,thick] (-\w/2,-\h/2) rectangle (\w/2,\h/2);
\draw [->,thick] (\w/2,0) -- (\w/2+\x,0);
\draw [->,thick] (-\w/2-\x,0) -- (-\w/2,0);
\node [left] at (-\w/2-\x,0) {Input};
\node [right] at (\w/2+\x,0) {Output};
\node [align=left,font=\ttfamily] at (0,0) {\small function(\subnode {sub}{...}) \{\\\hspace{0.2cm}...\\\}};
\draw[−>,thick] (-\w/2,0) -- (-\w/2 + \w/8,0) -- (-\w/2 + \w/8,\h/4) -- ($ (sub)+(-\w/2.5,\h/5) $) -- ($ (sub)+(0,\h/5) $) -- (sub);
\draw [->,thick] (0,0) -- (\w/2,0);
\end{tikzpicture}
```
Where header.tex
is:
\documentclass{article}
\include{preview}
\usepackage[pdftex,active,tightpage]{preview}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix}
% OWN CODE START
\usetikzlibrary{math}
\usetikzlibrary{tikzmark}
\usetikzlibrary{calc}
% OWN CODE END
\begin{document}
\begin{preview}
%% TIKZ_CODE %%
\end{preview}
\end{document}
When I run blogdown::build_site()
, I get this error:
Quitting from lines 184-195 (mypost.Rmd) Error: Failed to compile tikz1137adfc9b89.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See tikz1137adfc9b89.log for more info. Execution halted Error in render_page(f) : Failed to render 'content/mypost.Rmd'
file tikz1137adfc9b89.tex
is (the last lines showing the error):
! Package tikz Error: I did not find the tikz library 'tikzmark'. I looked for
files named tikzlibrarytikzmark.code.tex and pgflibrarytikzmark.code.tex, but n
either could be found in the current texmf trees..
See the tikz package documentation for explanation.
Type H <return> for immediate help.
...
l.9 \usetikzlibrary{tikzmark}
Here is how much of TeX's memory you used:
12142 strings out of 494553
251420 string characters out of 6174236
281626 words of memory out of 5000000
15624 multiletter control sequences out of 15000+600000
3640 words of font info for 14 fonts, out of 8000000 for 9000
14 hyphenation exceptions out of 8191
55i,0n,68p,420b,90s stack positions out of 5000i,500n,10000p,200000b,80000s
! ==> Fatal error occurred, no output PDF file produced!
I am on Mac, on Windows this works :(