我正在研究乳胶构建过程的配置,以便与 Anki 一起使用,编译带有乳胶内容的卡片。我有一些 eps 图形,想包含在我的一些卡片上。最新版本的 Anki 使用 pdflatex,它无法处理 eps 图像。我已将 epstopdf 添加到我的软件包列表中,并且安装了 ghostscript,但我收到错误,指示无法打开 ghostscript 进行管道输入。我是否可以将某些内容添加到构建配置中以强制 epstopdf 找到 ghostscript?
我可以从命令行手动转换 eps 文件:
epstopdf --debug /Images/commontriangles.eps commontriangles.pdf
我在使用 OSX Catalina。
这是我尝试时得到的结果which gs
:
/usr/local/bin/gs
错误如下:
Error executing pdflatex.
Generated file: /var/folders/v_/5s080r992cvfltv_256bmxyr0000gp/T/anki_temp/tmp.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=pdflatex)
\write18 enabled.
entering extended mode
(./tmp.tex
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-03-06>
(/usr/local/texlive/2020/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
(/usr/local/texlive/2020/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2020/texmf-dist/tex/latex/jknapltx/mathrsfs.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/changepage/changepage.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2020/texmf-dist/tex/generic/iftex/ifvtex.sty
(/usr/local/texlive/2020/texmf-dist/tex/generic/iftex/iftex.sty)))
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics-def/pdftex.def)))
(/usr/local/texlive/2020/texmf-dist/tex/latex/epstopdf-pkg/epstopdf.sty
(/usr/local/texlive/2020/texmf-dist/tex/generic/infwarerr/infwarerr.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/grfext/grfext.sty
(/usr/local/texlive/2020/texmf-dist/tex/generic/kvdefinekeys/kvdefinekeys.sty))
(/usr/local/texlive/2020/texmf-dist/tex/latex/kvoptions/kvoptions.sty
(/usr/local/texlive/2020/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty)
(/usr/local/texlive/2020/texmf-dist/tex/generic/kvsetkeys/kvsetkeys.sty))
(/usr/local/texlive/2020/texmf-dist/tex/latex/pdftexcmds/pdftexcmds.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg)))
(/usr/local/texlive/2020/texmf-dist/tex/latex/l3backend/l3backend-pdfmode.def)
(./tmp.aux)
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
(/usr/local/texlive/2020/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
)epstopdf ($Id: epstopdf.pl 48681 2018-09-16 23:03:58Z karl $) 2.28
!!! Error: Cannot open Ghostscript for piped input: gs -q -dSAFER -dNOPAUSE -dBATCH -dCompatibilityLevel=1.5 -sDEVICE=pdfwrite -sOutputFile=/Images/commontriangles-eps-converted-to.pdf -dPDFSETTINGS#/prepress -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -dAutoRotatePages#/None - -c quit
system returned with code 512
Underfull \hbox (badness 10000) in paragraph at lines 14--15
Underfull \hbox (badness 10000) in paragraph at lines 14--15
Underfull \hbox (badness 10000) in paragraph at lines 17--18
! Package pdftex.def Error: File `/Images/commontriangles-eps
-converted-to.pdf' not found: using draft setting.
See the pdftex.def package documentation for explanation.
Type H <return> for immediate help.
...
l.23 \includegraphics{commontriangles.eps}
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsfonts/umsb.fd)
(/usr/local/texlive/2020/texmf-dist/tex/latex/jknapltx/ursfs.fd) [1{/usr/local/
texlive/2020/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (./tmp.aux) )
(see the transcript file for additional information)</usr/local/texlive/2020/te
xmf-dist/fonts/type1/public/amsfonts/cm/cmbx9.pfb></usr/local/texlive/2020/texm
f-dist/fonts/type1/public/amsfonts/cm/cmmi9.pfb></usr/local/texlive/2020/texmf-
dist/fonts/type1/public/amsfonts/cm/cmr7.pfb></usr/local/texlive/2020/texmf-dis
t/fonts/type1/public/amsfonts/cm/cmr9.pfb></usr/local/texlive/2020/texmf-dist/f
onts/type1/public/amsfonts/cm/cmtt9.pfb>
Output written on tmp.pdf (1 page, 53488 bytes).
Transcript written on tmp.log.
这是我的构建配置:
{
"pngCommands": [
[
"pdflatex",
"--shell-escape",
"-interaction=nonstopmode",
"tmp.tex"
],
[
"dvipng",
"-D",
"200",
"-T",
"tight",
"tmp.dvi",
"-o",
"tmp.png"
]
],
"svgCommands": [
[
"pdflatex",
"--shell-escape",
"-interaction=nonstopmode",
"tmp.tex"
],
[
"dvisvgm",
"--no-fonts",
"-Z",
"2",
"tmp.dvi",
"-o",
"tmp.svg"
]
]
}
以下是我在卡上使用的包:
\documentclass[10pt,letterpaper]{article}
\usepackage{amssymb,amsmath,amsfonts,mathrsfs,changepage}
\usepackage[letterpaper,pass]{geometry}
\usepackage{graphicx}
\usepackage{epstopdf}
\graphicspath{ {/Images/} }
\pagestyle{empty}
\setlength{\parindent}{0in}
\DeclareMathOperator{\sech}{sech}
\DeclareMathOperator{\csch}{csch}
\begin{document}
答案1
所以,这里发生了几件事,但我将发布 Anki 找不到我的 Ghostscript 安装的问题的解决方案。显然,从 Finder 启动的 GUI 应用程序的环境变量值与PATH
终端窗口的环境变量值不同。因此,通常用于设置的 bash/zsh 文件PATH
不适用于 GUI 应用程序。
我的 Ghostscript 安装在我的系统上的 GUI 应用程序/usr/local/bin/gs
中,但它并不存在于其中。PATH
我在这里找到了解决方案:https://stackoverflow.com/questions/55648312/mac-os-x-mojave-set-environment-variable-permanently在此答案中具体如下:
https://stackoverflow.com/a/58164730/2200733
还有其他适用于旧版 OSX 的解决方案,但这些解决方案在后续版本中被删除了。我的系统是 Catalina,10.15.7。此解决方案对我有用,并且在重启后仍然存在。
我在这里复制并粘贴整个解决方案:
步骤 1:转到您的$HOME/Library/LaunchAgents
目录并创建setenv.MY_VAR.plist
包含以下内容的文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>setenv.MY_VAR</string>
<key>ProgramArguments</key>
<array>
<string>/bin/launchctl</string>
<string>setenv</string>
<string>MY_VAR</string>
<string>SOME_VALUE_FOR_MY_VAR</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
请注意您的文件名和文件中的条目是否匹配。
步骤2:运行launchctl load ~/Library/LaunchAgents/setenv.MY_VAR.plist
或重新启动系统。
步骤3:重新启动您的终端应用程序。
步骤 4:检查 var 是否存在:env
。它应该给你:MY_VAR=SOME_VALUE_FOR_MY_VAR
。
如果您想做更多更改,请先launchctl unload...
重复上述操作launchctl load...
。
这是针对每个用户的设置。如果要为所有用户设置,请尝试在 中执行相同操作/Library/LaunchAgents
。
我的设置的另一个问题是它pdflatex
不生成dvi
文件。因此,dvipng
它不是用于将中间结果转换为文件的合适程序png
。无论如何,该问题的修复已发布在我的一个老问题上:
Anki 2.1 + Latex + Graphicx 并包含 eps 图像:如何配置 Anki,以便我可以使用 graphicx 包含 eps 图像