summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/tikzinclude/tikzinclude.sty
blob: f5fb8c74d8904fcaa3694d583511d7020acd19ac (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
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
%%
%% This is file `tikzinclude.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% tikzinclude.dtx  (with options: `package')
%% 
%% Copyright (C) 2012 by Ferdinand Schwenk (me@nerdifand.de).
%% Copyright (C) 2012 by Benjamin Berg (benjamin@sipsolutions.net).
%% 
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. The latest version of this license is available at
%% http://www.latex-project.org/lppl/.
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{tikzinclude}
    [2012/22/02 v1.0 package for including only a specified tikz pictures from a file]
\RequirePackage{tikz}
\RequirePackage{ifthen}
\RequirePackage{etoolbox}
\newif\if@tikzinclude@active\@tikzinclude@activefalse
\let\@tikzinclude@typsetpicturebox\pgfsys@typesetpicturebox
\newcommand{\@tikzinclude@picture@started}{%
  \if@tikzinclude@active%
    \let\par\@tikzinclude@par%
  \fi%
}
\newcommand{\@tikzinclude@picture@ended}{%
  \if@tikzinclude@active%
    \ifthenelse{%
      \equal{\pgfkeysvalueof{/tikzinclude/figure}}{\pgfkeysvalueof{/tikzinclude/select}}%
    }%
    {}%
    {%
      \global\def\pgfsys@typesetpicturebox##1{%
        \global\let\pgfsys@typesetpicturebox\@tikzinclude@typsetpicturebox%
      }%
    }%
  \fi%
}
\BeforeBeginEnvironment{tikzpicture}{\if@tikzinclude@active%
  \whileboolexpr{test{\ifdimgreater{\lastskip}{0pt}}}{\unskip}\fi}%
  \AtBeginEnvironment{tikzpicture}{\@tikzinclude@picture@started%
}
\AtEndEnvironment{tikzpicture}{\@tikzinclude@picture@ended}
\AfterEndEnvironment{tikzpicture}{\ignorespaces}
\pgfkeyssetvalue{/tikzinclude/figure}{}
\pgfkeyssetvalue{/tikzinclude/select}{}
\newcommand\includetikzgraphics[2][]{%
  \begingroup%
    \ifthenelse{\equal{#1}{}}%
    {%
      \input{#2}%
    }%
    {%
      \let\@tikzinclude@par\par%
      \def\par{}%
      \pgfkeyssetvalue{/tikzinclude/select}{#1}%
      \@tikzinclude@activetrue%
      \kern0pt\input{#2}%
      \whileboolexpr{test{\ifdimgreater{\lastskip}{0pt}}}{\unskip}%
      \@tikzinclude@activefalse%
      \let\par\@tikzinclude@par%
    }%
  \endgroup%
}
\endinput
%%
%% End of file `tikzinclude.sty'.