summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/stex/source/extensions/tikzinput.dtx
blob: 51a3a7c06aa46efce54cc966e86959037ff31e33 (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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
% \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>
\providecommand\bibfolder{../../lib/bib}
\input{../../doc/docheader}

\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% \title{Tikzinput
% 	\thanks{Version {\fileversion} (last revised {\filedate})} 
% }
%
% \author{Michael Kohlhase, Dennis Müller\\
% 	FAU Erlangen-Nürnberg\\
% 	\url{http://kwarc.info/}
% }
%
% \maketitle
%
%\ifinfulldoc\else
% This is the documentation for the \pkg{tikzinput} package.
% For a more high-level introduction, 
%  see \href{\basedocurl/manual.pdf}{the \sTeX Manual} or the
% \href{\basedocurl/stex.pdf}{full \sTeX documentation}.
%
% \input{../../doc/packages/tikzinput}
% \fi
%
% \begin{documentation}\label{pkg:tikzinput:doc}
%
%
% \section{Macros and Environments}\label{pkg:tikzinput:doc:macros}
%
% \end{documentation}
%
% \begin{implementation}\label{pkg:tikzinput:impl}
%
% \section{Tikzinput Implementation}
%
%    \begin{macrocode}
%<*package>

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

%    \end{macrocode}
%
%    \begin{macrocode}
\ProvidesExplPackage{tikzinput}{2022/02/24}{3.0.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}
}

\@ifpackageloaded{stex}{
  \RequirePackage{stex-tikzinput}
}{}

%    \end{macrocode}
%
%
%    \begin{macrocode}
%</package>
%<*stex>
%    \end{macrocode}
%
%    \begin{macrocode}
\ProvidesExplPackage{stex-tikzinput}{2022/02/24}{3.0.0}{stex-tikzinput}
\RequirePackage{stex}
\RequirePackage{tikzinput}

\newcommand\mhtikzinput[2][]{%
  \def\Gin@mhrepos{}\setkeys{Gin}{#1}%
  \stex_in_repository:nn\Gin@mhrepos{
    \tikzinput[#1]{\mhpath{##1}{#2}}
  }
}
\newcommand\cmhtikzinput[2][]{\begin{center}\mhtikzinput[#1]{#2}\end{center}}
%    \end{macrocode}
%
%    \begin{macrocode}
%</stex>
%    \end{macrocode}
%
% \end{implementation}
%
% \PrintIndex

%  LocalWords:  bibfolder jobname.dtx tikzinput.dtx usetikzlibrary Gin@ewidth Gin@eheight
%  LocalWords:  resizebox ctikzinput mhtikzinput Gin@mhrepos mhpath