![升级到 luatex 0.95 后 pinlabel 不起作用](https://linux22.com/image/334900/%E5%8D%87%E7%BA%A7%E5%88%B0%20luatex%200.95%20%E5%90%8E%20pinlabel%20%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8.png)
我pinlabel
在我的项目中广泛使用了该软件包,并使用 LuaLaTeX 进行编译。在最近升级到 MiKTeX 2.9 后,我无法再编译该项目,并出现大量错误,例如
! Undefined control sequence. <argument> \pdfximagebbox
\pdflastximage 1
l.19 \includegraphics[width=5cm]{pdf_figure}
和
! Undefined control sequence.
<argument> \pdfximagebbox
\pdflastximage 2 l.19 \includegraphics[width=5cm]{pdf_figure}
在分析了日志文件并阅读了 TSE 上的类似错误报告后,我认为问题可能是由 LuaTeX 0.95 和以下几行引起的pinlabel
,用于确定 pdf 图像的边界框:
% Next five lines of code supplied by Mark Petelier
%
% Read BB from pdf file:
%
\pdfximage cropbox {\@filestem.pdf}
\@p@@sbbllx{\pdfximagebbox\pdflastximage 1}
\@p@@sbblly{\pdfximagebbox\pdflastximage 2}
\@p@@sbburx{\pdfximagebbox\pdflastximage 3}
\@p@@sbbury{\pdfximagebbox\pdflastximage 4}
LuaTeX 手册建议我使用外部应用程序或 img 库来替换\pdfximagebbox
命令,但是我对 (Lua)TeX 的了解不足以实现它。因此我的问题是:pinlabel
使用 LuaTeX 0.95 的最佳方法是什么?
梅威瑟:
% !TeX TXS-program:compile = txs:///lualatex/
\documentclass[11pt,twoside,a4paper]{article}
% the following package seems to be necessary to enable use of pdf images with pinlabel after upgrade to luatex 0.95
\usepackage{luatex85}
\usepackage{pinlabel}
\usepackage{graphicx}
\begin{document}
Math in graphics: \\
\labellist
\pinlabel $X$ at 200 200
\endlabellist
% Two cases, uncomment one of them
%
% MWE compiles well with the following line; the BB information is taken from the corresponding example-image.eps file, I guess
% \includegraphics[width=5cm]{example-image}
%
% MWE does not compile with lualatex 0.95 if using any pdf file without corresponding eps file. The examle compiles well usin pdftex.
\includegraphics[width=5cm]{pdf_figure}
\end{document}
答案1
我认为您可以修补代码以使用 lua 图像库,如下所示:
\documentclass[11pt,twoside,a4paper]{article}
% the following package seems to be necessary to enable use of pdf images with pinlabel after upgrade to luatex 0.95
\usepackage{luatex85}
\usepackage{pinlabel}
\usepackage{graphicx}
\makeatletter
\def\foo#1\pdfximage#2\no@bbfalse#3\foo{%
\def\scan@header{#1%
\directlua{a = img.scan { filename = "\@filestem.pdf"}
tex.print(\the\catcodetable@atletter,
"\string\\@p@@sbburx{" .. a.width .. "sp}\string\\@p@@sbbury{" .. a.height .. "sp}")
}%
\@p@@sbbllx{\z@}%
\@p@@sbblly{\z@}%
%
\no@bbfalse#3}}%
\expandafter\foo\scan@header\foo
\makeatother
\begin{document}
Math in graphics: \\
\labellist
\pinlabel $X$ at 200 200
\endlabellist
% Two cases, uncomment one of them
%
% MWE compiles well with the following line; the BB information is taken from the corresponding example-image.eps file, I guess
% \includegraphics[width=5cm]{example-image}
%
% MWE does not compile with lualatex 0.95 if using any pdf file without corresponding eps file. The examle compiles well usin pdftex.
\includegraphics[width=5cm]{pdf_figure}
\end{document}
也许可以使用 bbox 而不是高度 + 深度,但对于 pdf 文件包含,我认为 llx 和 lly 始终为 0。