如何為缺少的圖形建立佔位符?

如何為缺少的圖形建立佔位符?

我正在使用 寫論文texlive2013dummy figure方案 這裡

在此輸入影像描述

但是,不只缺失的人物被替換了,其他正常的人物也被替換了,有沒有辦法解決呢?

答案1

一個小解決方法,但肯定不完美(取決於圖形擴展,它可能會失敗)——我\IfFileExists在稍微重新定義的\includegraphics命令中使用了 。它測試四個擴展名(全部小寫)(.eps、和).pdf.jpg.png

\documentclass{scrbook}

\usepackage{blindtext}
\usepackage{graphicx}
\usepackage{tcolorbox}


\let\StandardIncludeGraphics\includegraphics%
\renewcommand{\includegraphics}[2][]{%
\IfFileExists{#2.eps}{%
  \StandardIncludeGraphics[#1]{#2}%
}{%
 \IfFileExists{#2.pdf}{%
  \StandardIncludeGraphics[#1]{#2}%
  }{ % No, no .pdf, try *.jpg 
   \IfFileExists{#2.jpg}{%
    \StandardIncludeGraphics[#1]{#2}%
    }{
      \IfFileExists{#2.png}{%
      \StandardIncludeGraphics[#1]{#2}%
      }{%
      \begin{tcolorbox}[width=6cm,height=4cm,arc=0mm,auto outer arc]
      \end{tcolorbox}
     }
   }
 }
}% 
%
}% End of command



\begin{document}



\chapter{First one}
\blindtext

\begin{figure}
\begin{center}

\includegraphics[width=10cm,height=8cm]{some_file}
\caption{My demo figure}
\end{center}
\end{figure}
\blindtext[2]


\end{document}

some_file我的路徑中根本不存在提到的文件。

在此輸入影像描述

相關內容