-
Notifications
You must be signed in to change notification settings - Fork 7
/
robustize-figures.tex
99 lines (92 loc) · 2.65 KB
/
robustize-figures.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
\let\StandardIncludeGraphics\includegraphics
%==========================================
% CREDITS: https://tex.stackexchange.com/a/567990/221054
\makeatletter
\newif\ifgraphicexist
\catcode`\*=11
\newcommand\imagetest[1]{%
\begingroup
\global\graphicexisttrue
\ifx\detokenize\@undefined\else
\edef\Gin@extensions{\detokenize\expandafter{\Gin@extensions}}%
\fi
\let\input@path\Ginput@path
\set@curr@file{#1}%
\expandafter\filename@parse\expandafter{\@curr@file}%
\ifx\filename@ext\Gin@gzext
\expandafter\filename@parse\expandafter{\filename@base}%
\ifx\filename@ext\relax
\let\filename@ext\Gin@gzext
\else
\edef\Gin@ext{\Gin@ext\Gin@sepdefault\Gin@gzext}%
\fi
\fi
\ifx\filename@ext\relax
\@for\Gin@temp:=\Gin@extensions\do{%
\ifx\Gin@ext\relax
\Gin@getbase\Gin@temp
\fi}%
\else
\Gin@getbase{\Gin@sepdefault\filename@ext}%
\ifx\Gin@ext\relax
\global\graphicexistfalse
\let\Gin@savedbase\filename@base
\let\Gin@savedext\filename@ext
\edef\filename@base{\filename@base\Gin@sepdefault\filename@ext}%
\let\filename@ext\relax
\@for\Gin@temp:=\Gin@extensions\do{%
\ifx\Gin@ext\relax
\Gin@getbase\Gin@temp
\fi}%
\ifx\Gin@ext\relax
\let\filename@base\Gin@savedbase
\let\filename@ext\Gin@savedext
\fi
\fi
\ifx\Gin@ext\relax
\global\graphicexistfalse
\def\Gin@base{\filename@area\filename@base}%
\edef\Gin@ext{\Gin@sepdefault\filename@ext}%
\fi
\fi
\ifx\Gin@ext\relax
\global\graphicexistfalse
\else
\@ifundefined{Gin@rule@\Gin@ext}%
{\global\graphicexistfalse}%
{}%
\fi
\ifx\Gin@ext\relax
\gdef\imageextension{unknown}%
\else
\xdef\imageextension{\Gin@ext}%
\fi
\endgroup
\ifgraphicexist
\expandafter \@firstoftwo
\else
\expandafter \@secondoftwo
\fi
}
\catcode`\*=12
\makeatother
%==========================================
\newcommand{\shrug}{\texttt{\raisebox{0.75em}{\char`\_}\char`\\\char`\_\kern-0.5ex(\kern-0.25ex\raisebox{0.25ex}{\rotatebox{45}{\raisebox{-.75ex}"\kern-1.5ex\rotatebox{-90})}}\kern-0.5ex)\kern-0.5ex\char`\_/\raisebox{0.75em}{\char`\_}}}
\renewcommand{\includegraphics}[2][]{%
%
\imagetest{#2}{
\StandardIncludeGraphics[#1]{#2}
}{
\ClassWarning{robustize-figures}{Figure #2 does not exist -- but robust mode is activated, so I am going to replace this with a placeholder}
\noindent\colorbox{gray!20}{
\begin{minipage}[t][4.2cm][t]{0.8\textwidth}
\vspace*{\fill}
\centering
Missing figure
\texttt{#2}
\medskip
\tikzifintikzpicture{(-:}{\shrug}
\vspace*{\fill}
\end{minipage}}
}
}