我想使用以下命令序列编译以下内容:
lualatex document.tex
asy document-1.asy
lualatex document.tex
但是,此操作失败并显示以下消息:
! error: (file "document-1".pdf) (pdf backend): cannot find image file '"document-1".pdf'
! ==> Fatal error occurred, no output PDF file produced!
如果我替换lualatex
为pdflatex
或,xelatex
代码就可以正常工作。这是使用 mactex 2017。测试文档如下:
\documentclass{article}
\usepackage{graphicx}
\usepackage{asymptote}
\begin{document}
Hello.
I like to make pics with Asymptote like this one:
\begin{figure}[h]
\begin{asy}
include graph;
size(1inch);
filldraw(circle((0,0),1),yellow,black);
fill(circle((-.3,.4),.1),black);
fill(circle((.3,.4),.1),black);
draw(arc((0,0),.5,-140,-40));
\end{asy}
\end{figure}
\par It makes me happy,
since I can still type my normal LaTeX stuff around it:
\(\int_0^{\pi}{\sin{x}}\,dx=2\)
\end{document}
我的问题是:如何使它与 lualatex(我将其用于我的主要文档)一起工作?
答案1
我尝试重写以下几行asymptote.sty
:
\documentclass{article}
\usepackage{graphicx}
\usepackage{asymptote}
\usepackage{ifluatex}
\ifluatex
\makeatletter
\def\asy@input@graphic{%
\ifASYinline
\IfFileExists{"\AsyFile.tex"}{%
\catcode`:=12\relax
\@@input"\AsyFile.tex"\relax
}{%
\PackageWarning{asymptote}{file `\AsyFile.tex' not found}%
}%
\else
\IfFileExists{"\AsyFile.\AsyExtension"}{%
\ifASYattach
\ifASYPDF
\IfFileExists{"\AsyFile+0.pdf"}{%
\setbox\ASYbox=\hbox{\includegraphics[hiresbb]{\AsyFile+0.pdf}}%
}{%
\setbox\ASYbox=\hbox{\includegraphics[hiresbb]{\AsyFile.pdf}}%
}%
\else
\setbox\ASYbox=\hbox{\includegraphics[hiresbb]{\AsyFile.eps}}%
\fi
\textattachfile{\AsyFile.\AsyExtension}{\phantom{\copy\ASYbox}}%
\vskip-\ht\ASYbox
\indent
\box\ASYbox
\else
\ifASYPDF
\includegraphics[hiresbb]{\AsyFile.pdf}%
\else
\includegraphics[hiresbb]{\AsyFile.eps}%
\fi
\fi
}{%
\IfFileExists{"\AsyFile.tex"}{%
\catcode`:=12
\@@input"\AsyFile.tex"\relax
}{%
\PackageWarning{asymptote}{%
file `\AsyFile.\AsyExtension' not found%
}%
}%
}%
\fi
}
\makeatother
\fi
\begin{document}
Hello.
I like to make pics with Asymptote like this one:
\begin{figure}[h]
\begin{asy}
include graph;
size(1inch);
filldraw(circle((0,0),1),yellow,black);
fill(circle((-.3,.4),.1),black);
fill(circle((.3,.4),.1),black);
draw(arc((0,0),.5,-140,-40));
\end{asy}
\end{figure}
\par It makes me happy,
since I can still type my normal LaTeX stuff around it:
\(\int_0^{\pi}{\sin{x}}\,dx=2\)
\end{document}
答案2
为了处理包含空格的文件名,引号是必需的,不幸的是许多用户坚持这样做。如果删除引号,lualatex 可以工作,但只能处理不包含空格的文件名。我将检查 TeXLive 2017 中的 lualatex 是否已修复以丢弃引号。
答案3
那应该是
asy document-1.asy
代替
asy document-1.tex
这将会产生错误。