同時載入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 in --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 931 oparray_pop 1915 1 3 %oparray_pop 1803 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringvaling --nostringval-- 2 %stopped_pushstrnostring--nostringvaling--nostringval-- 2 %stopped_push --nostring--nostringvaling-- 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。

==> 2 頁寫在「bug0001-problem-pics.pdf」上。

我仍在追蹤我在實際專案中遇到的問題:我根本沒有得到條碼。該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}

或使用xelatexand運行它

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

答案2

最好不要知道我在一個有截止日期的實際專案中花了多少時間在這個專案上,因為在升級 TeX Live 發行版/TikZ 後我沒有得到任何條碼。當然,我可以使用單獨的 TeX 檔案來處理條碼,好吧,我想解決這個問題。

該問題肯定是 TikZ 3 引起的,因為我的程式碼正在使用 TikZ 2auto-pst-pdf運行。在產生 DVI 輸出時,我基本上透過將命令包裝在by 中來限制TikZ 3 套件的載入。如果我們產生 PDF 檔案(實際排版),則會載入 TikZ 3 包,如果我們產生 DVI 檔案(在系統 shell 中產生條碼),我們會跳過該載入。然後就沒有錯誤訊息了:pst-pdflatex->dvips->ps2pdf->pdfcrop\usepackage{tikz}\ifpdf ... \filualatex\ifcsname directlua\endcsname ... \fi

PDFCROP 1.38,2012/11/02 - 版權所有 (c) 2002-2012,作者:Heiko Oberdiek。

==> 2 頁寫在「bug0001-solution-pics.pdf」上。

我附上我的解決方案和頁面預覽。

%! 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}

一個辦法

相關內容