summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/stex/source/tikzinput.dtx
blob: da4615fbbea521cb7e8d9f34deaf981ce5ead8e7 (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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
% \iffalse meta-comment
% An Infrastructure for Semantic Macros and Module Scoping
% Copyright (c) 2019 Michael Kohlhase, all rights reserved
%                this file is released under the
%                LaTeX Project Public License (LPPL)
% 
% The original of this file is in the public repository at 
% http://github.com/sLaTeX/sTeX/
%
% TODO update copyright  
%
%<*driver>
\def\stexdocpath{../doc}
\input{\stexdocpath/stex-docheader}
\stextoptitle{Tikzinput: Treating TIKZ code as images}{tikzinput}
\docmodule
%</driver>
% \fi
%
% \begin{stexmanual}
%    \begin{sfragment}{Tikzinput Manual}
	%      \input{\stexdocpath/packages/stex-tikzinput}
%    \end{sfragment}
% \end{stexmanual}
%
% \begin{documentation}
%    \begin{sfragment}{Tikzinput Documentation}
%       TODO
%    \end{sfragment}
% \end{documentation}
%
% \begin{implementation}\label{pkg:tikzinput:impl}
%
% \begin{sfragment}{Tikzinput Implementation}
%
%    \begin{macrocode}
%<@@=tikzinput>
%<*package>

%%%%%%%%%%%%%   tikzinput.dtx   %%%%%%%%%%%%%

%    \end{macrocode}
%
%    \begin{macrocode}
\ProvidesExplPackage{tikzinput}{2023/10/13}{3.4.0}{tikzinput package}
\RequirePackage{l3keys2e}

\keys_define:nn { tikzinput } {
  image   .bool_set:N   = \c_tikzinput_image_bool,
  image   .default:n    = false ,
  unknown   .code:n       = {}
}

\ProcessKeysOptions { tikzinput }

\bool_if:NTF \c_tikzinput_image_bool {
  \RequirePackage{graphicx}

  \providecommand\usetikzlibrary[]{}
  \newcommand\tikzinput[2][]{\includegraphics[#1]{#2}}
}{
  \RequirePackage{tikz}
  \RequirePackage{standalone}

  \newcommand \tikzinput [2] [] {
    \setkeys{Gin}{#1}
    \ifx \Gin@ewidth \Gin@exclamation
      \ifx \Gin@eheight \Gin@exclamation
        \input { #2 }
      \else
        \resizebox{!}{ \Gin@eheight }{
          \input { #2 }
        }
      \fi
    \else
      \ifx \Gin@eheight \Gin@exclamation
        \resizebox{ \Gin@ewidth }{!}{
          \input { #2 }
        }
      \else
        \resizebox{ \Gin@ewidth }{ \Gin@eheight }{
          \input { #2 }
        }
      \fi
    \fi
  }
}

\newcommand \ctikzinput [2] [] {
  \begin{center}
    \tikzinput [#1] {#2}
  \end{center}
}
%    \end{macrocode}
%
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
% \end{sfragment}
% \end{implementation}
%
\endinput
% Local Variables:
% mode: doctex
% TeX-master: t
% End:

%  LocalWords:  libfolder jobname.dtx tikzinput.dtx usetikzlibrary Gin@ewidth Gin@eheight
%  LocalWords:  ctikzinput mhpath pgfkeys@spdef pgfutil@empty 1@atcode catcode l_tmpa_str
%  LocalWords:  pgfutil@InputIfFileExists libusetikzlibrary msg_error:nnn notinarchive
%  LocalWords:  seq_clear:N seq_set_eq:NN l_tmpa_seq c_stex_mathhub_seq seq_set_split:NnV
%  LocalWords:  l_tmpb_seq seq_if_empty_p:N tikzlibrary seq_put_right:No seq_pop_left:NN