我正在尝试使用tufte_handout
在R Markdown中生成一个tikz数字我在RStudio中运行它。这是我的sessionInfo()
:
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin16.1.0 (64-bit)
Running under: macOS Sierra 10.12.2
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] backports_1.0.4 magrittr_1.5 tufte_0.2 rprojroot_1.1 htmltools_0.3.5 tools_3.3.2 yaml_2.1.14 Rcpp_0.12.8
[9] stringi_1.1.2 rmarkdown_1.3 knitr_1.15.1 stringr_1.1.0 digest_0.6.11 evaluate_0.10
我的例子(还没有工作)是:
---
title: "TikzTest"
output:
tufte::tufte_handout: default
---
This is a test of the R Markdown tufte_handout.^[This is a sidenote in the tufte_handout] To use the tikz package, you have to include this code chunk:
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE,dev = 'tikz')
library(tikzDevice)
```
But it doesn't work?:
```{r,engine='tikz'}
\begin{tikzpicture}[line width=0.05cm]
\node [align=center] (x) at (0,0) {$X$};
\node [align=center] (y) at (2.55,0) {$Y$};
\begin{scope}[line width=.05cm,shorten >= 5pt, shorten <= 5pt]
\draw[->,color=black] (x) to (y);
\end{scope}
\end{tikzpicture}
```
当我编织这个时,我收到以下错误:
Error in tools::texi2dvi(texf, pdf = !to_svg, clean = TRUE) :
Running 'texi2dvi' on './tikz145322b8f468.tex' failed.
Messages:
sh: /usr/local/opt/texinfo/bin/texi2dvi: No such file or directory
Calls: <Anonymous> ... call_block -> block_exec -> in_dir -> engine -> <Anonymous>
Execution halted
我安装了MacTeX-2016发行版
答案 0 :(得分:0)
我没有Mac,但是我在运行您提供的代码时遇到了同样的错误。为了解决这个问题,我所要做的只是采取这一行:
line:knitr::opts_chunk$set(echo = TRUE,dev = 'tikz')
并将其更改为以下内容:
knitr::opts_chunk$set(echo = TRUE)
通过这种改变,它可以正常工作,我想象的是你正在寻找的输出。希望这也适用于Mac。