summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/stex/extensions/tikzinput.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/stex/extensions/tikzinput.dtx')
-rw-r--r--Master/texmf-dist/source/latex/stex/extensions/tikzinput.dtx83
1 files changed, 74 insertions, 9 deletions
diff --git a/Master/texmf-dist/source/latex/stex/extensions/tikzinput.dtx b/Master/texmf-dist/source/latex/stex/extensions/tikzinput.dtx
index f183a6e4fad..fb7bbf76c97 100644
--- a/Master/texmf-dist/source/latex/stex/extensions/tikzinput.dtx
+++ b/Master/texmf-dist/source/latex/stex/extensions/tikzinput.dtx
@@ -10,7 +10,7 @@
% TODO update copyright
%
%<*driver>
-\providecommand\bibfolder{../../lib/bib}
+\def\bibfolder#1{../../lib/bib/#1}
\input{../../doc/stex-docheader}
\begin{document}
@@ -19,7 +19,7 @@
%</driver>
% \fi
%
-% \title{Tikzinput
+% \title{Tikzinput: Treating TIKZ code as images
% \thanks{Version {\fileversion} (last revised {\filedate})}
% }
%
@@ -30,12 +30,20 @@
%
% \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}.
+% \ifinfulldoc\else
+% \begin{abstract}
+% 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}.
+%
+% In some situations it is more efficient externalize the TIKZ pictures into separate
+% (standalone) files, to let {\LaTeX} handle the TIKZ pictures to generate an image, and
+% just load it via the usual {\LaTeX} graphics packages. The |tikzinput| package
+% supports this workflow, and allows to switch back to native TIKZ via a package option.
+% \end{abstract}
%
+% \tableofcontents
+%
% \input{../../doc/packages/stex-tikzinput}
% \fi
%
@@ -51,6 +59,7 @@
% \section{Tikzinput Implementation}
%
% \begin{macrocode}
+%<@@=tikzinput>
%<*package>
%%%%%%%%%%%%% tikzinput.dtx %%%%%%%%%%%%%
@@ -58,7 +67,7 @@
% \end{macrocode}
%
% \begin{macrocode}
-\ProvidesExplPackage{tikzinput}{2022/02/26}{3.0.1}{tikzinput package}
+\ProvidesExplPackage{tikzinput}{2022/05/24}{3.1.0}{tikzinput package}
\RequirePackage{l3keys2e}
\keys_define:nn { tikzinput } {
@@ -121,7 +130,7 @@
% \end{macrocode}
%
% \begin{macrocode}
-\ProvidesExplPackage{stex-tikzinput}{2022/02/26}{3.0.1}{stex-tikzinput}
+\ProvidesExplPackage{stex-tikzinput}{2022/05/24}{3.1.0}{stex-tikzinput}
\RequirePackage{stex}
\RequirePackage{tikzinput}
@@ -132,6 +141,61 @@
}
}
\newcommand\cmhtikzinput[2][]{\begin{center}\mhtikzinput[#1]{#2}\end{center}}
+
+\cs_new_protected:Nn \_@@_usetikzlibrary:nn {
+ \pgfkeys@spdef\pgf@temp{#1}
+ \expandafter\ifx\csname tikz@library@\pgf@temp @loaded\endcsname\relax%
+ \expandafter\global\expandafter\let\csname tikz@library@\pgf@temp @loaded\endcsname=\pgfutil@empty%
+ \expandafter\edef\csname tikz@library@#1@atcode\endcsname{\the\catcode`\@}
+ \expandafter\edef\csname tikz@library@#1@barcode\endcsname{\the\catcode`\|}
+ \expandafter\edef\csname tikz@library@#1@dollarcode\endcsname{\the\catcode`\$}
+ \catcode`\@=11
+ \catcode`\|=12
+ \catcode`\$=3
+ \pgfutil@InputIfFileExists{#2}{}{}
+ \catcode`\@=\csname tikz@library@#1@atcode\endcsname
+ \catcode`\|=\csname tikz@library@#1@barcode\endcsname
+ \catcode`\$=\csname tikz@library@#1@dollarcode\endcsname
+}
+
+
+\newcommand\libusetikzlibrary[1]{
+ \prop_if_exist:NF \l_stex_current_repository_prop {
+ \msg_error:nnn{stex}{error/notinarchive}\libusetikzlibrary
+ }
+ \prop_get:NnNF \l_stex_current_repository_prop {id} \l_tmpa_str {
+ \msg_error:nnn{stex}{error/notinarchive}\libusetikzlibrary
+ }
+ \seq_clear:N \l_@@_libinput_files_seq
+ \seq_set_eq:NN \l_tmpa_seq \c_stex_mathhub_seq
+ \seq_set_split:NnV \l_tmpb_seq / \l_tmpa_str
+
+ \bool_while_do:nn { ! \seq_if_empty_p:N \l_tmpb_seq }{
+ \str_set:Nx \l_tmpa_str {\stex_path_to_string:N \l_tmpa_seq / meta-inf / lib / tikzlibrary #1 .code.tex}
+ \IfFileExists{ \l_tmpa_str }{
+ \seq_put_right:No \l_@@_libinput_files_seq \l_tmpa_str
+ }{}
+ \seq_pop_left:NN \l_tmpb_seq \l_tmpa_str
+ \seq_put_right:No \l_tmpa_seq \l_tmpa_str
+ }
+
+ \str_set:Nx \l_tmpa_str {\stex_path_to_string:N \l_tmpa_seq / lib / tikzlibrary #1 .code.tex}
+ \IfFileExists{ \l_tmpa_str }{
+ \seq_put_right:No \l_@@_libinput_files_seq \l_tmpa_str
+ }{}
+
+ \seq_if_empty:NTF \l_@@_libinput_files_seq {
+ \msg_error:nnxx{stex}{error/nofile}{\exp_not:N\libusetikzlibrary}{tikzlibrary #1 .code.tex}
+ }{
+ \int_compare:nNnTF {\seq_count:N \l_@@_libinput_files_seq} = 1 {
+ \seq_map_inline:Nn \l_@@_libinput_files_seq {
+ \_@@_usetikzlibrary:nn{#1}{ ##1 }
+ }
+ }{
+ \msg_error:nnxx{stex}{error/twofiles}{\exp_not:N\libusetikzlibrary}{tikzlibrary #1 .code.tex}
+ }
+ }
+}
% \end{macrocode}
%
% \begin{macrocode}
@@ -139,6 +203,7 @@
% \end{macrocode}
%
% \end{implementation}
+% \ifinfulldoc\else\printbibliography\fi
%
% \PrintIndex