TikZ 和外部:無明顯原因重新創建的人物

TikZ 和外部:無明顯原因重新創建的人物

我遇到一個問題,儘管使用了該tikz/external庫,但僅重新創建了多個圖形中的一個。我創建了一個 MWE,僅用兩個圖表就可以顯示相同的效果。

下面是我的主文件,它是用pdflatex -shell-escape file.

\documentclass{article}

\usepackage{tikz,pgfplots,tikzscale}
\usetikzlibrary{external}
\tikzexternalize[prefix=figures/]
\pgfplotsset{compat=newest}
\graphicspath{ {./figures/}{./figures-tikz/} }

\newcommand{\figFilename}{}

\begin{document}
  \begin{figure}[t!]
    \renewcommand{\figFilename}{scalability-plot-all-sbb-2-optima}
    \centering
    \tikzpicturedependsonfile{\figFilename.tikz}
    \tikzsetnextfilename{\figFilename}
    \includegraphics[width=\textwidth,axisratio=1]{\figFilename.tikz}
    \caption{Scalability plot for dDE, MPC, dDE$^-$ and a hill climber on the Scalable-Building-Block problem.}
    \label{fig:\figFilename}
  \end{figure}

  \begin{figure}[t!]
    \renewcommand{\figFilename}{scalability-plot-all-sbb-2-optima-log-y}
    \centering
    \tikzpicturedependsonfile{\figFilename.tikz}
    \tikzsetnextfilename{\figFilename}
    \includegraphics[width=\textwidth,axisratio=1]{\figFilename.tikz}
    \caption{Same as in Figure~\ref{fig:scalability-plot-all-sbb-2-optima}, but y axis is in logscale.}
    \label{fig:\figFilename}
  \end{figure}
\end{document}

每次運行時都會重新建立第一個圖形pdflatex。我嘗試更改兩者的順序,但這並沒有什麼區別——帶有文件名的圖形scalability-plot-all-sbb-2-optima是始終重新創建的圖形,即使另一個圖形相同但帶有 a semilogyaxis。兩者的檔案TikZ只是五個addplot命令,它們從五個不同的 .dat 檔案載入資料。在這裡顯示所有內容會佔用大量空間,所以這裡有一個關聯整個目錄結構,包括.tex.tikz.dat文件。

我發現如果我只保留一個 addplot,則不會重新建立該圖。我想知道這是否是一個錯誤,是否LaTeX被我的目錄結構混淆,或者這只是我的一個錯誤。

答案1

由於我的 LaTeX 知識非常有限,我決定檢查日誌檔案 ( file.log) 以嘗試找出問題所在。我注意到在導致重新生成圖片的轉換命令之後,出現了此類錯誤:

Overfull \hbox (17.03157pt too wide) in paragraph at lines 1--76
 [][] 
 []

這讓我相信它tikzscale無法將圖片縮放到我要求的確切尺寸,這導致了tikzscale圖片尺寸與實際尺寸之間的不匹配。實際上曾是。所以我所做的就是按照中列出的說明進行操作答案是刪除 x 和 y 標籤周圍的空白(基本上嘗試提供幫助tikzscale)。

問題現已解決。警告Overfull \hbox不再出現,圖片也不再每次重新生成。我不知道這是否是預期的行為,或者這是否是一個錯誤。

相關內容