先前版本的 Anki 编译此代码没有任何问题:
\begin{center}
\includegraphics[scale=0.4]{recursion_tree.eps}
\end{center}
升级到 2.1 后,我无法编译上述代码。我向anki.tenderapp.com 并被告知 Anki 2.1 使用 pdflatex,它不支持开箱即用的 eps 文件。开发人员还说我的用例太小众,不值得操心,所以我必须自己解决这个问题。我在 Google 上搜索了很多,但一直找不到解决这个问题的直接方法。有没有简单的修复方法可以使此代码编译,或者我必须找到其他方法在 latex 环境中将图像包含在卡片中?我尝试只添加 png,但一直收到过满错误。我宁愿不必每次想要包含图像时都指定图像大小。旧版 Anki 的好处是,我似乎从来没有收到过有关图像大小的任何错误。它“刚刚起作用”:
我的系统:
Mac OSX Catalina
TexLive 2019
I have dvipng installed
我收到上述乳胶代码的以下错误消息:
Error executing dvipng.
Generated file: /var/folders/3t/67vlbpbx73l1l1m5yj8plvhr0010zw/T/anki_temp/tmp.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=latex)
restricted \write18 enabled.
entering extended mode
(./tmp.tex
LaTeX2e <2019-10-01> patch level 3
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/10/25 v1.4k Standard LaTeX document class
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/stackengine/stackengine.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(/usr/local/texlive/2019/texmf-dist/tex/generic/listofitems/listofitems.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/listofitems/listofitems.tex))
(/usr/local/texlive/2019/texmf-dist/tex/latex/tools/calc.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/mathtools/mathtools.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/mathtools/mhsetup.sty))
(/usr/local/texlive/2019/texmf-dist/tex/generic/systeme/systeme.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/xstring/xstring.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/xstring/xstring.tex))
(/usr/local/texlive/2019/texmf-dist/tex/generic/systeme/systeme.tex))
(/usr/local/texlive/2019/texmf-dist/tex/latex/braket/braket.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/jknapltx/mathrsfs.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/changepage/changepage.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/adjustbox/adjustbox.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/xkeyval/xkvutils.tex)))
(/usr/local/texlive/2019/texmf-dist/tex/latex/adjustbox/adjcalc.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/adjustbox/trimclip.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics-def/dvips.def)))
(/usr/local/texlive/2019/texmf-dist/tex/latex/collectbox/collectbox.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/adjustbox/tc-dvips.def))
(/usr/local/texlive/2019/texmf-dist/tex/latex/ifoddpage/ifoddpage.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/varwidth/varwidth.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/clrscode3e/clrscode3e.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/makecell/makecell.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/tools/array.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/multirow/multirow.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/tools/tabularx.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3packages/xfrac/xfrac.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/expl3-code.tex
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/l3deprecation.def))
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3backend/l3backend-dvips.def))
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/textcomp.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/ts1enc.def
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/ts1enc.dfu)))
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate.st
y)) (/usr/local/texlive/2019/texmf-dist/tex/latex/units/units.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/ifthen.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/units/nicefrac.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/iftex/ifpdf.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/iftex/iftex.sty))
(/usr/local/texlive/2019/texmf-dist/tex/generic/iftex/ifvtex.sty)
(/usr/local/texlive/2019/texmf-dist/tex/generic/iftex/ifxetex.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/pgf/frontendlayer/tikz.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/pgf/basiclayer/pgf.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/pgf/utilities/pgfrcs.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.te
x
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/utilities/pgfutil-common-li
sts.tex))
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/utilities/pgfutil-latex.def
(/usr/local/texlive/2019/texmf-dist/tex/latex/ms/everyshi.sty))
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/utilities/pgfrcs.code.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/pgf.revision.tex)))
(/usr/local/texlive/2019/texmf-dist/tex/latex/pgf/basiclayer/pgfcore.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/pgf/systemlayer/pgfsys.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/systemlayer/pgfsys.code.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.c
ode.tex))
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/systemlayer/pgf.cfg)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-dvips.de
f
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-common-p
ostscript.def)))
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/systemlayer/pgfsyssoftpath.
code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/systemlayer/pgfsysprotocol.
code.tex)) (/usr/local/texlive/2019/texmf-dist/tex/latex/xcolor/xcolor.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics-cfg/color.cfg))
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcore.code.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathcalc.code.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathutil.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathparser.code.tex
)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.code.
tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.basic
.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigo
nometric.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.rando
m.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.compa
rison.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.base.
code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round
.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.
code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.integ
erarithmetics.code.tex)))
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex)
) (/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfint.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepoints.co
de.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathconst
ruct.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathusage
.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcorescopes.co
de.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcoregraphicst
ate.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretransform
ations.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcorequick.cod
e.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreobjects.c
ode.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathproce
ssing.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcorearrows.co
de.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreshade.cod
e.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreimage.cod
e.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreexternal.
code.tex))
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcorelayers.co
de.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretranspare
ncy.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepatterns.
code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/basiclayer/pgfcorerdf.code.
tex)))
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/modules/pgfmoduleshapes.cod
e.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/modules/pgfmoduleplot.code.
tex)
(/usr/local/texlive/2019/texmf-dist/tex/latex/pgf/compatibility/pgfcomp-version
-0-65.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/pgf/compatibility/pgfcomp-version
-1-18.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/pgf/utilities/pgffor.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/pgf/utilities/pgfkeys.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex)
) (/usr/local/texlive/2019/texmf-dist/tex/latex/pgf/math/pgfmath.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex))
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/utilities/pgffor.code.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex)))
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/frontendlayer/tikz/tikz.cod
e.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/libraries/pgflibraryplothan
dlers.code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/modules/pgfmodulematrix.cod
e.tex)
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/frontendlayer/tikz/librarie
s/tikzlibrarytopaths.code.tex)))
(/usr/local/texlive/2019/texmf-dist/tex/latex/booktabs/booktabs.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/umsb.fd)
(/usr/local/texlive/2019/texmf-dist/tex/latex/jknapltx/ursfs.fd) (./tmp.aux)
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/ts1cmr.fd)
*geometry* driver: auto-detecting
*geometry* detected driver: dvips
ABD: EveryShipout initializing macros
Underfull \hbox (badness 10000) in paragraph at lines 26--27
</Users/sephilli/Pictures/recursion_tree.eps> [1] (./tmp.aux) )
(see the transcript file for additional information)
Output written on tmp.dvi (1 page, 14344 bytes).
Transcript written on tmp.log.
卡片模板:
[latex]
{\scriptsize GENERAL KNOWLEDGE \newline}
{\small
{{Answer}} }
<br>
\begin{flushright} {\scriptsize {{Subject}} } \end{flushright}
[/latex]
卡片样式:
.card {
font-family: arial;
font-size: 10px;
text-align: center;
color: black;
background-color: white;
}
img {
width: auto;
height: auto;
max-height:1000px;
}
卡片选项的标题:
\documentclass[10pt,letterpaper]{article}
\usepackage{amssymb,stackengine,amsmath,mathtools,systeme,braket,amsfonts,mathrsfs,changepage,mathtools, adjustbox,clrscode3e,makecell,multirow,tabularx,xfrac,units}
\usepackage[letterpaper,pass]{geometry}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{booktabs}
\pagestyle{empty}
\setlength{\parindent}{0in}
\stackMath
\graphicspath{ {/Users/sephilli/Pictures/} }
\newsavebox\boxofmathplus
\sbox{\boxofmathplus}{$+$}
\setcellgapes{1pt}
\newcommand{\spaceforemptycolumn}{\makebox[\wd\boxofmathplus]{\ }}
\newlength{\grsteplength}\setlength{\grsteplength}{1.5ex plus .1ex minus .1ex}
\newcommand{\grstep}[2][\relax]{\ensuremath{\mathrel{\hspace{\grsteplength}\mathop{\longrightarrow}\limits^{#2\mathstrut}_{\begin{subarray}{l} #1 \end{subarray}}\hspace{\grsteplength}}}}\newcommand{\repeatedgrstep}[2][\relax]{\hspace{-\grsteplength}\grstep[#1]{#2}}
\newenvironment{linsys}[2][m]{\setlength{\arraycolsep}{.1111em}\begin{array}[#1]{@{}*{#2}{rc}r@{}}}{\end{array}}
\newenvironment{amatrix}[1]{\left(\begin{array}{@{}*{#1}{c}|c@{}}}{\end{array}\right)}
\newenvironment{mat}[1][c]{\begin{pmatrix*}}{\end{pmatrix*}}
\newcommand{\colvec}[2][c]{\begin{mat}[#1] #2 \end{mat}}
\newcommand{\rowvec}[1]{\setlength{\arraycolsep}{3pt}(\begin{matrix} #1 \end{matrix})}
\begin{document}
卡片选项的页脚:
\end{document}
Latex 构建过程的配置:
{
"pngCommands": [
[
"latex",
"-interaction=nonstopmode",
"tmp.tex"
],
[
"dvipng",
"-D",
"200",
"-T",
"tight",
"tmp.dvi",
"-o",
"tmp.png"
]
],
"svgCommands": [
[
"latex",
"-interaction=nonstopmode",
"tmp.tex"
],
[
"dvisvgm",
"--no-fonts",
"-Z",
"2",
"tmp.dvi",
"-o",
"tmp.svg"
]
]
}
答案1
经过很长一段时间的思考,我终于找到了解决方案。以下是让 Anki 2.1 与包含eps
图像的 latex 标记一起工作的有效设置:
安装编辑 LaTex 构建过程插件
使用以下内容作为
pngCommands
节:"pngCommands": [ [ "pdflatex", "--shell-escape", "-interaction=nonstopmode", "tmp.tex", "tmp.pdf" ], [ "/usr/local/bin/convert", "-density", "200", "-trim", "tmp.pdf", "tmp.png" ] ]
安装
imagemagick
和ghostscript
将包添加到使用标记且需要包含图像
epstopdf
的卡片类型的标题中:latex
eps
\usepackage{epstopdf}
我没有测试使用imagemagick
convert
命令来生成svg
图像。我相信,有了上面的例子,任何想这样做的人都能弄清楚如何去做。
pdflatex
不会生成dvi
图像,因此我最初的尝试(基于我为旧版 Anki 设置的设置)不适用于使用 的 Anki 2.1 pdflatex
。中间文件是一个pdf
文件。因此,dvipng
我需要使用 之类的东西,而不是 来imagemagick
将中间文件转换为png
图像。
为了pdflatex
处理eps
转换pdf
,该epstopdf
包是必需的。
当我完成所有这些工作时,我还遇到了 Anki 不知道 Ghostscript 安装在哪里的问题。当我尝试预览带有eps
图像的卡片时,它们会出错,因为找不到 Ghostscript。我在这里发布了一个问题以及我找到的解决方案: