Blogdown无法在我的Rmd文档中渲染tikz块

时间:2019-03-19 06:11:36

标签: r rstudio r-markdown blogdown

此问题与this question密切相关,但是存在以下差异:

  • 操作系统::带有Windows主机的Docker容器(图像为centos)中的Unix CentOS。
  • 错误:从概念上讲,相同的错误,但是在Windows上无法正常运行的修复程序在此起作用,并且错误消息也有所不同。

我已经使用模板Hugo-Xmin创建了一个项目。在RStudio中,在Blogdown中创建项目后,它创建了一些预定义的帖子,我正在编辑此帖子:

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myapp.settings')

application = get_wsgi_application()

我通过在文件末尾添加以下代码段来修改了该文件:

/content/post/2015-07-23-r-rmarkdown.Rmd

无法处理帖子

我的工作目录是项目文件夹,我从那里运行,在R控制台中,命令:

This is a tikz picture:

```{r, echo=FALSE, engine='tikz', out.width='90%', fig.ext=if (knitr:::is_latex_output()) 'pdf' else 'png', fig.cap='Some caption.'}
\begin{tikzpicture}[scale=.7]
\draw [fill=gray!30,very thick] (0,-1) rectangle (5,1);
\draw [very thick] (5, 0) -- (13,0);
\node [below] at (2,-1) {\large Hello};
\node [below, align=center] at (0,-1) {\large Two\\ lines};
\end{tikzpicture}
```

并得到这个:

blogdown::build_site()

重要:请注意,我已遵循帮助链接,并在文件开头添加了以下代码段:

> blogdown::build_site()
Rendering content/_index.Rmarkdown
running: bash  -c "cd ../..;
find . -not -path '*/exampleSite/*' \\( -name '*.html' -o -name '*.css' \\) | xargs wc -l"
Rendering content/post/2015-07-23-r-rmarkdown.Rmd
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
 restricted \write18 enabled.
entering extended mode
! LaTeX Error: File `preview.sty' not found.

! Emergency stop.
<read *>

Quitting from lines 49-55 (2015-07-23-r-rmarkdown.Rmd)
Error: Failed to compile tikz2b145b766cfa.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See tikz2b145b766cfa.log for more info.
Execution halted
Error in render_page(f) :
  Failed to render 'content/post/2015-07-23-r-rmarkdown.Rmd'

我在上面报告的输出是在此代码段到位后得到的输出。


故障排除1

通过检查文件```{r, include=FALSE} options(tinytex.verbose = TRUE) ``` (如错误消息中所述),我可以看到以下错误:

tikz2b145b766cfa.log

重要的是要知道我已经在CentOS系统上安装了许多软件包和软件:

This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013) (format=pdflatex 2019.3.18)  18 MAR 2019 21:12
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**tikz2b145b766cfa.tex
(./tikz2b145b766cfa.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, ru
ssian, ukrainian, bulgarian, loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2007/10/19 v1.4h Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
\@input{preview.aux}
\openout2 = `preview.aux'.

No file preview.tex.

! LaTeX Error: File `preview.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name:
! Emergency stop.
<read *>

l.4 \usepackage
               {amsmath}^^M
Here is how much of TeX's memory you used:
 200 strings out of 494820
 2171 string characters out of 3178049
 47774 words of memory out of 3000000
 3480 multiletter control sequences out of 15000+200000
 3640 words of font info for 14 fonts, out of 3000000 for 9000
 198 hyphenation exceptions out of 8191
 23i,0n,17p,164b,36s stack positions out of 5000i,500n,10000p,200000b,50000s

!  ==> Fatal error occurred, no output PDF file produced!

并且:

yum install texlive*

在R。

故障排除2

根据建议,我安装了:install.packages("devtools") remotes::install_github('yihui/knitr') install.packages(c('magick', 'pdftools')) 。成功了。之后,在运行tinytex之后,总是提示我缺少必须安装的库。 30分钟后,我收到此消息:

build_site()

很遗憾,我已经为此问题苦苦挣扎,因为已经安装了> blogdown::build_site() Rendering content/_index.Rmarkdown running: bash -c "cd ../..; find . -not -path '*/exampleSite/*' \\( -name '*.html' -o -name '*.css' \\) | xargs wc -l" Rendering content/post/2015-07-23-r-rmarkdown.Rmd hugo: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by hugo) hugo: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by hugo) ,并且不确定如何修复libstdc++-4.8.5-36.el7.x86_64GLIBCXX_3.4.20。对它们尝试GLIBCXX_3.4.21无效。

1 个答案:

答案 0 :(得分:1)

我不知道为什么您的TeX Live无法找到preview.sty,但是我很确定TinyTeX会自动运行:

# first make sure all your R packages are up-to-date, then
tinytex::install_tinytex()