【问题标题】:Running R tikzDevice with tinytex: Help troubleshooting `! LaTeX Error: File `tikz.sty' not found`使用 tinytex 运行 R tikzDevice:帮助故障排除`! LaTeX 错误:找不到文件“tikz.sty”
【发布时间】:2022-06-24 21:34:18
【问题描述】:

我正在尝试通过 tikzDevice 包使用 R/ggplot2 生成 tikz 图。当我弄清楚如何在我的 docker 映像上安装 R 和 tinytex 时,我不得不经历许多错误,但我遇到了以下错误,这让我很困惑。

当我运行生成我的情节的代码时,这是我得到的错误:

Error in getMetricsFromLatex(TeXMetrics, verbose = verbose) : 
TeX was unable to calculate metrics for:

        \char77

Run the following commands for diagnosis:

        tikzTest()
        tikzTest("\\char77")

Common reasons for failure include:
  * The string contains a character which is special to LaTeX unless
    escaped properly, such as % or $.
  * The string makes use of LaTeX commands provided by a package and
    the tikzDevice was not told to load the package.

The TeX and log files used for the calculation can help diagnose the
problem. If these files are missing, rerun the plot and make sure to
keep the R session open.
TeX file: tikzStringWidthCalc.tex
Log file: tikzStringWidthCalc.log
Calls: <Anonymous> ... descentDetails.text -> grid.Call -> <Anonymous> -> getMetricsFromLatex
Execution halted

tikzDevice::tikzTest()的输出如下:

Active compiler:
        /home/jovyan/.TinyTeX/bin/x86_64-linux/pdflatex
        pdfTeX 3.141592653-2.6-1.40.23 (TeX Live 2021)
        kpathsea version 6.3.3

Measuring dimensions of: A
Running command: '/home/jovyan/.TinyTeX/bin/x86_64-linux/pdflatex' -interaction=batchmode -halt-on-error -output-directory '/tmp/RtmpLhckyy/tikzDevice29a5e00452e' 'tikzStringWidthCalc.tex'
This is pdfTeX, Version 3.141592653-2.6-1.40.23 (TeX Live 2021) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode

TeX was unable to calculate metrics for:

        A

Contents of TeX file tikzStringWidthCalc.tex:

\documentclass[10pt]{article}

\usepackage{tikz}

\usepackage[active,tightpage,psfixbb]{preview}

\PreviewEnvironment{pgfpicture}

\setlength\PreviewBorder{0pt}

\usepackage{tikz}
\usepackage[T1]{fontenc}

\usetikzlibrary{calc}

\batchmode
\begin{document}
\begin{tikzpicture}
\node[inner sep=0pt, outer sep=0pt, scale=1] (TeX) {A};
\path let \p1 = ($(TeX.east) - (TeX.west)$),
    \n1 = {veclen(\x1,\y1)} in (TeX.east) -- (TeX.west)
    node{ \typeout{tikzTeXWidth=\n1} };
\end{tikzpicture}
\end{document}
Contents of log file tikzStringWidthCalc.log:

This is pdfTeX, Version 3.141592653-2.6-1.40.23 (TeX Live 2021) (preloaded format=pdflatex 2022.3.16)  16 MAR 2022 23:30
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**tikzStringWidthCalc.tex
(/tmp/RtmpLhckyy/tikzDevice29a5e00452e/tikzStringWidthCalc.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-02-24> (/home/jovyan/.TinyTeX/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/home/jovyan/.TinyTeX/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2021/10/04 v1.4n Standard LaTeX file (size option)
)
\c@part=\count185
\c@section=\count186
\c@subsection=\count187
\c@subsubsection=\count188
\c@paragraph=\count189
\c@subparagraph=\count190
\c@figure=\count191
\c@table=\count192
\abovecaptionskip=\skip47
\belowcaptionskip=\skip48
\bibindent=\dimen138
)

! LaTeX Error: File `tikz.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 ^^M
        
Here is how much of TeX's memory you used:
 235 strings out of 480236
 3181 string characters out of 5895451
 287032 words of memory out of 5000000
 18278 multiletter control sequences out of 15000+600000
 469259 words of font info for 28 fonts, out of 8000000 for 9000
 14 hyphenation exceptions out of 8191
 34i,0n,38p,138b,36s stack positions out of 5000i,500n,10000p,200000b,80000s

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

如您所见,我使用的是 tinytex,但我已按照 tinytex documentation 中的说明安装了此设置的推荐软件包(即,我已经运行了 tlmgr install pgf preview xcolor)。

我已经阅读了所有可能找到的关于这个主题的帖子,但我没有找到。任何帮助我解决此问题的提示将不胜感激。

【问题讨论】:

    标签: r docker tikz tinytex tikzdevice


    【解决方案1】:

    如果您有一个最低限度的可重现示例来检查我们的结果,那将会有所帮助。
    这就是说,消息LaTeX Error: File `tikz.sty' not found. 表明可能的解决方案是您抛出:

    library(tinytex)
    tlmgr_search('/tikz.sty')    # search for tikz.sty
    tlmgr_install('pgf')         # install the psnfss package
    tlmgr_update()               # update everything
    

    因为tlmgr_search('/tikz.sty')给了你

    tlmgr search --file --global "/tikz.sty"
    tlmgr.pl: package repository https://ctan.mirror.garr.it/mirrors/ctan/systems/texlive/tlnet 
    pgf:
        texmf-dist/tex/latex/pgf/frontendlayer/tikz.sty
    

    但是您已经安装了pgf...这就是tikz.sty 所在的位置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多