
考慮這個 MWE:
% to rebuild:
% rm test-testplot.pdf ; pdflatex -shell-escape test.tex
\RequirePackage{filecontents}
\begin{filecontents*}{testplot.tikz}
\begin{tikzpicture}
\begin{axis}[
width=500pt,
height=195pt,
clip=true,
axis x line=middle,
axis y line=middle,
]
\end{axis}
\end{tikzpicture}
\end{filecontents*}
\documentclass[11pt]{book}
\usepackage[
paperwidth=15cm,
paperheight=20cm,
outer=2.5cm,
inner=2.5cm,
top=2.5cm,
bottom=2.5cm
]{geometry}
\usepackage[a4,cam,center]{crop}
\usepackage{tikz,pgfplots,adjustbox,lipsum}
\usetikzlibrary{external}
\tikzexternalize[] %activate!
\begin{document}
\lipsum[1]
\tikzsetnextfilename{\tikzexternalrealjob-testplot}
\begin{figure}[!ht]
\begin{adjustbox}{width=\textwidth}%
\input{./testplot.tikz}
\end{adjustbox}
\caption{Just trying to insert a plot picture here}
\label{fig:test}
\end{figure}
\end{document}
結果有點奇怪,因為實際頁面頂部的裁剪標記被捕獲在tikz
包含pgfplots
!的圖像的 PDF 上。仔細觀察(透過在 PDF 檢視器中選擇該區域;點擊查看完整解析度):
……事實證明,crop
包簽名也被捕獲,儘管是隱藏的。整個頁面,包括外部化的 pdf,顯示在右側。
這次我做錯了什麼,如何在不捕捉裁剪標記的情況下外部化這個 tikz pgfplot ? (不用說,我希望從主文檔中完成外部化,因此所有頁面大小、字體等更改都被考慮在內)。
編輯:我一直在同一文件中將 tikz 外部化與其他幾個 tikz 圖像一起使用(但是,沒有使用pgfplots
),據我所知,它們沒有問題......但也許我應該重新-查看
答案1
使用以下命令建立圖像時禁止載入裁剪\tikzifexternalizing
:(不要忘記刪除舊圖片或強制重新創建)
\documentclass[11pt]{book}
\usepackage[
paperwidth=15cm,
paperheight=20cm,
outer=2.5cm,
inner=2.5cm,
top=2.5cm,
bottom=2.5cm
]{geometry}
\usepackage{tikz,pgfplots,adjustbox,lipsum}
\usetikzlibrary{external}
\tikzexternalize[] %activate!
\tikzifexternalizing{}{\usepackage[a4,cam,center]{crop}}
\begin{document}
\lipsum[1]
\tikzsetnextfilename{\tikzexternalrealjob-testplot}
\begin{figure}[!ht]
\begin{adjustbox}{width=\textwidth}%
\input{./testplot.tikz}
\end{adjustbox}
\caption{Just trying to insert a plot picture here}
\label{fig:test}
\end{figure}
\end{document}