同时加载 TikZ3+PSTricks

同时加载 TikZ3+PSTricks

我也发布了我的解决方案。请节省您在这个问题上的时间和精力!

auto-pst-pdf在将 TikZ 2 升级到 TikZ 3 后,同时加载和使用 TikZ 和 PSTricks 包(通过)时,我遇到了奇怪的行为。请考虑生成条形码的这种情况。

%! latex or pdflatex or xelatex or lualatex
%! with ----shell-escape or --enable-write18
%! bug0001-problem.tex
\documentclass[a4paper]{article}
\pagestyle{empty}
\usepackage{pst-barcode}
\usepackage{auto-pst-pdf}
\usepackage{tikz}
\begin{document}
My first barcode is:\par
\begin{pspicture}(3,1in)
\psbarcode{978-80-87106-00-6}{includetext guardwhitespace}{isbn}
\end{pspicture}\par
My first QR code is:\par
\begin{pspicture}(1,1in)
\psbarcode{http://www.cstug.cz/}{}{qrcode}
\end{pspicture}\par
\begin{tikzpicture}
\node{Hello World!};
\end{tikzpicture}
\end{document}

我在使用 TikZ 2 时没有遇到问题,但在使用 TikZ 3 时收到此错误消息。

错误:/typecheck 在 --div--

操作数堆栈:

1 2 0.0 TeXcolorgray 65781.8

执行堆栈:

%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1932 1 3 %oparray_pop 1931 1 3 %oparray_pop 1915 1 3 %oparray_pop 1803 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- 5 --nostringval-- %repeat_continue --nostringval--

字典堆栈:

--字典:1180/1684(ro)(G)-- --字典:0/20(G)-- --字典:126/200(L)-- --字典:179/300(L)--

当前分配模式为本地

当前文件位置为 601489

GPL Ghostscript 9.10:无法恢复的错误,退出代码 1

PDFCROP 1.38,2012/11/02 - 版权所有 (c) 2002-2012 Heiko Oberdiek。

==> 在“bug0001-problem-pics.pdf”上写了2页。

我仍在追踪我在实际项目中遇到的问题:我根本没有条形码。该realproject.pdf文件是空的,因此pdfcrop生成了一个错误,并且没有 PDF 文件的裁剪版本。我的项目很大,所以我还无法在小范围内模拟我的真实情况。如果我这样做,我会扩展这个问题。尽管如此,我无法将产生这种错误的 TeX 代码交给 TeXist/出版商,因为我无法通过或隐藏\batchmode\nonstopmode

我的问题是:当加载 TikZ 3 时,如何修复它,以便不会像 TikZ 2 中那样收到此类错误消息?

答案1

运行它pdflatex --shell-escape

\documentclass[a4paper]{article}
\pagestyle{empty}
\usepackage{pst-barcode}
\usepackage{auto-pst-pdf}
\ifpdf\usepackage{tikz}\fi 
\begin{document}

My first barcode is:\par
\begin{pspicture}(3,1in)
\psbarcode{978-80-87106-00-6}{includetext guardwhitespace}{isbn}
\end{pspicture}\par
My first QR code is:\par
\begin{pspicture}(1,1in)
\psbarcode{http://www.cstug.cz/}{}{qrcode}
\end{pspicture}\par
\begin{tikzpicture}
\node{Hello World!};
\end{tikzpicture}

\end{document}

xelatex或者用and运行它

\documentclass[a4paper]{article}
\pagestyle{empty}
\usepackage{pst-barcode}
\usepackage{tikz}
\begin{document}
[...]

答案2

最好不要知道我在有最后期限的实际项目中花了多少时间在这个问题上,因为在升级 TeX Live 发行版/TikZ 后,我没有得到条形码。当然,我可以使用单独的 TeX 文件来处理条形码,好吧,我想解决这个问题。

问题肯定是 TikZ 3 引起的,因为我的代码是使用 TikZ 2 运行的。包auto-pst-pdf正在调用pst-pdf包,它调用系统 shell( )。我基本上通过将命令包装为或例如包装为来latex->dvips->ps2pdf->pdfcrop限制在生成 DVI 输出时对 TikZ 3 包的加载。如果我们生成 PDF 文件(实际排版),则会加载 TikZ 3 包,如果我们生成 DVI 文件(在系统 shell 中生成条形码),我们会跳过该加载。然后没有错误消息:\usepackage{tikz}\ifpdf ... \filualatex\ifcsname directlua\endcsname ... \fi

PDFCROP 1.38,2012/11/02 - 版权所有 (c) 2002-2012 Heiko Oberdiek。

==> 在“bug0001-solution-pics.pdf”上写了2页。

我附上了我的解决方案和页面预览。

%! pdflatex or xelatex or lualatex
%! with ----shell-escape or --enable-write18
%! bug0001-solution.tex
\documentclass[a4paper]{article}
\pagestyle{empty}
\usepackage{pst-barcode}
\usepackage{auto-pst-pdf}
\ifpdf
% This is another approach when running lualatex:
% \ifcsname directlua\endcsname
\usepackage{tikz}
% Plus loading tikz libraries...
\else
% Or run \batchmode or \nonstopmode as pst-pdf does...
\newenvironment{tikzpicture}[1]{}{}
\def\tikzset{}
\fi 
\begin{document}
My first barcode is:\par
\begin{pspicture}(3,1in)
\psbarcode{978-80-87106-00-6}{includetext guardwhitespace}{isbn}
\end{pspicture}\par
My first QR code is:\par
\begin{pspicture}(1,1in)
\psbarcode{http://www.cstug.cz/}{}{qrcode}
\end{pspicture}\par
\begin{tikzpicture}
\node{Hello World!};
\end{tikzpicture}
\end{document}

一个办法

相关内容