防止 Tikz 外部化重建圖形

防止 Tikz 外部化重建圖形

我正在使用 Tikz externalize 來處理手稿中的圖形。包含 Tikz/pgfplots 程式碼的原始檔案已被刪除(但當我的模擬運行完成後,將在幾個小時內重新生成)。

同時,我想對文本進行一些修改,並將其交給其他人進行審查。我仍然保留著先前 Tikz 編譯的輸出檔。有沒有辦法阻止 Tikz 嘗試重建這些文件並按原樣使用它們?

答案1

當您至少提供一些虛擬tikz;命令或\begin{tikzpicture} \end{tikzpicture}環境時,這是可能的。

您沒有提供有關 TikZ 程式碼的範例,因此我無法詳細建議您應該如何做。因為您寫的是「完成模擬」並且您正在使用 PGFPlots,所以我假設您想要顯示一些模擬結果圖。最好只存儲數據在一些資料檔案中並將它們繪製為\addplot table {<filename>};.那麼可能/應該只發生這些資料檔案在模擬運行期間被刪除,但tikzpicture環境本身仍然存在。那麼下面的解決方案將非常適合您。

有關更多詳細信息,請查看程式碼中的註釋和PGFPlots 手冊第 530 頁 (v1.14) 中的「在未安裝 PGF 或 PGFPlots 的情況下使用庫」部分

\documentclass[border=5pt]{standalone}
% -----------------------------------------------------------------------------
% use this block to externalize your figures
\usepackage{pgfplots}
    \usetikzlibrary{
        % at present the PGFPlots External library is newer as the one in
        % TikZ so I use this one
        % (some bugs are fixed in it)
        pgfplots.external,
    }
    \tikzexternalize[
        % Because I think it is good practice to give your to externalize
        % pictures a name, I use the following option
        only named=true,
    ]
%% -----------------------------------------------------------------------------
%% use this block after externalizing
%% the only thing that needs to be present is either a `\tikz ...' command
%% or a `tikzpicture environment'
%% (copy the file
%%  <tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternal.sty>
%% into the directory of your main file (\jobname) and rename it to
%% "tikzexternal.sty")
%\usepackage{tikzexternal}
%% -----------------------------------------------------------------------------
    % store the externalized files in the following folder
    % (this folder must already exist; otherwise you will get an error)
    \tikzsetexternalprefix{Pics/pgf-export/}
\begin{document}
    \tikzsetnextfilename{test}
    \begin{tikzpicture}
% -----------------------------------------------
% this part can be commented, deleted or whatever
% after externalization and further use of the
% `tikzexternal' package
        \begin{axis}
            \addplot coordinates { (0,0) };
        \end{axis}
% -----------------------------------------------
    \end{tikzpicture}
\end{document}

答案2

代替

\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize

%\usepackage{tikz}
\usepackage{graphicx}
\usepackage{tikzexternal}
%\usetikzlibrary{external}
\tikzexternalize

由於您沒有提供示例並且我從未這樣做過,因此未經測試。然而,它是中描述的方法50.5 在未安裝 PGF 的情況下使用外部顯示卡在鈦kZ 手冊,其中還討論了它用於加速編譯的用途。有關此方法的局限性,請參閱那裡的討論。有幾件事您需要確保以特定的方式而不是其他方式完成,其中external庫和 TikZ 本身支援多種方法來實現相同目標。

如果您正在使用pgfplots,您應該查閱其手冊而不是 PGF/TikZ 1 因為您可能正在使用其外部化工具而不是通用工具。看斯特凡·平諾的回答在這種情況下,這個過程似乎比平常的事情要簡單得多。

否則,請嘗試托比的建議

相關內容