
答案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
我的路徑中根本不存在提到的文件。