summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgf/utilities/pgfexternalwithdepth.tex
blob: f2b08b2a9e413eb7b691c2cf5269ec700f2279bd (plain)
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
% Copyright 2007 by Till Tantau
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.
%
% In addition to the above licenses, this particular file may also be
% directly inlined into other documents and this copyright notice may
% be removed. Additionally, when you inline this file, you may modify
% it as needed and you may remove comments.
%
% This file is intended to be distributed or even inlined into a file
% when a document needs to be typeset on a system that does not have
% pgf/TikZ installed.

% "environment" for reading an external graphic. Note that there are
% no (!) braces around the "name" of the environment
%
% #1 = name of the graphics file
%
% Example:
%
% \beginpgfgraphicnamed{mygraph}
%   \begin{tikzpicture}
%     ...
%   \end{tikzpicture}
% \endpgfgraphicnamed

\long\def\beginpgfgraphicnamed#1#2\endpgfgraphicnamed{%
    \begingroup
    \setbox1=\hbox{\includegraphics{#1}}%
    \openin1=#1.dpth
    \ifeof1    \box1
    \else
        \read1 to\pgfincludeexternalgraphicsdp    \closein1
        \dimen0=\pgfincludeexternalgraphicsdp\relax
        \hbox{\lower\dimen0 \box1 }%
    \fi
    \endgroup
}