I am trying to run some very basic TikZ code, such as:
```{r TikZtest, engine="tikz"}
\begin{tikzpicture}
\draw (0,0) -- (1,1);
\end{tikzpicture}
```
However, if I try to compile using gitbook in RStudio (e.g. by adding this code to 01-intro.Rmd in a new Bookdown project) then it exits:
==> rmarkdown::render_site(output_format = 'bookdown::gitbook', encoding = 'UTF-8')
processing file: _main.Rmd
|..... | 7%
inline R code fragments
|......... | 13%
label: unnamed-chunk-1 (with options)
List of 1
$ eval: logi FALSE
|.............. | 20%
ordinary text without R code
|................... | 27%
label: unnamed-chunk-2 (with options)
List of 1
$ eval: logi FALSE
|....................... | 33%
ordinary text without R code
|............................ | 40%
label: unnamed-chunk-3 (with options)
List of 1
$ include: logi FALSE
|................................. | 47%
ordinary text without R code
|..................................... | 53%
label: TikZtest (with options)
List of 2
$ engine : chr "tikz"
$ fig.ext: chr "png"
Exited with status 134.
This also crashes when using bookdown::pdf_book
and the fig.ext=png
option, which suggests a problem with RMagick. Running these rendering commands directly in R either on this same project or on just the TikZ chunk crashes R with the following message
/usr/include/c++/11/bits/basic_string.h:1136: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::back() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference = char&]: Assertion '!empty()' failed.
Aborted (core dumped)
which is the same message when trying to use the magick library to read the (successfully rendered) pdf figure from bookdown::pdf_book
:
library(magick)
x <- image_read_pdf("_main_files/figure-html/TikZtest-1.pdf")
and now I'm stumped! I don't even know where to look for help! I am running:
- Fedora Linux 35
- R version 4.1.2
- RStudio version 2021.09.1 Build 372
- RMagick version 2.7.3 which uses ImageMagick version 6.9.12.28
I would appreciate any help!