summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/stex/tikzinput/tikzinput.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/stex/tikzinput/tikzinput.dtx')
-rw-r--r--Master/texmf-dist/source/latex/stex/tikzinput/tikzinput.dtx210
1 files changed, 210 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/stex/tikzinput/tikzinput.dtx b/Master/texmf-dist/source/latex/stex/tikzinput/tikzinput.dtx
new file mode 100644
index 00000000000..73b26eac8c3
--- /dev/null
+++ b/Master/texmf-dist/source/latex/stex/tikzinput/tikzinput.dtx
@@ -0,0 +1,210 @@
+% \iffalse meta-comment
+% A LaTeX Package for selective input of external TIKZ pictures
+% Copyright (c) 2015 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/KWARC/sTeX/
+% \fi
+%
+% \iffalse
+%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+%<package>\ProvidesPackage{tikzinput}[2016/04/07 v1.0 Selective input of TIKZ pictures]
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{url,array,float}
+\usepackage{tikzinput,omdoc}
+\usepackage[show]{ed}
+\usepackage[hyperref=auto,style=alphabetic]{biblatex}
+\addbibresource{kwarcpubs.bib}
+\addbibresource{extpubs.bib}
+\addbibresource{kwarccrossrefs.bib}
+\addbibresource{extcrossrefs.bib}
+\usepackage{stex-logo}
+\usepackage{ctangit}
+\usepackage{hyperref}
+\makeindex
+\floatstyle{boxed}
+\newfloat{exfig}{thp}{lop}
+\floatname{exfig}{Example}
+\def\tracissue#1{\cite{sTeX:online}, \hyperlink{http://trac.kwarc.info/sTeX/ticket/#1}{issue #1}}
+\begin{document}\DocInput{tikzinput.dtx}\end{document}
+%</driver>
+% \fi
+%
+%\CheckSum{37}
+%
+% \changes{v1.0}{2015/10/22}{self-documenting package}
+%
+% \GetFileInfo{tikzinput.sty}
+%
+% \MakeShortVerb{\|}
+%
+% \def\omdoc{OMDoc}
+% \def\latexml{{\LaTeX}ML}
+% \title{\texttt{tikzinput}: Selective Input of TIKZ Pictures\thanks{Version {\fileversion} (last revised
+% {\filedate})}}
+% \author{Michael Kohlhase\\
+% Jacobs University, Bremen\\
+% \url{http://kwarc.info/kohlhase}}
+% \maketitle
+%
+% \begin{abstract}
+% Running |tikz| takes a lot of time in \latexml, therefore it is often 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\newpage
+%
+%\begin{omgroup}[id=sec:STR]{Introduction}
+%
+% Running |tikz| takes a lot of time in \latexml, therefore it is often 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.
+%
+% A side-effect of the workflow described above is that the TIKZ pictures can be
+% developed -- and formatted -- independently of the document they are intended
+% for. They can essentially be treated like an image file, which can be included into
+% multiple documents.
+%
+%\end{omgroup}
+%
+% \begin{omgroup}[id=sec:user]{The User Interface}
+%
+% \begin{omgroup}[id=sec:user:options]{Package Options}
+%
+% The behavior of the |tikzinput| package is determined by whether the
+% \DescribeMacro{image}|image| option is given. If it is not, then the |tikz| package is
+% loaded, all other options are passed on to it and |\tikzinput{|\meta{file}|}| inputs
+% the TIKZ file \meta{file}|.tex|; if not, only the |graphicx| package is loaded and
+% |\tikzinput{|\meta{file}|}| loads an image file \meta{file}|.|\meta{ext} generated
+% from \meta{file}|.tex|.
+%
+% \end{omgroup}
+%
+% \begin{omgroup}{Inputting Standalone TIKZ Pictures}
+%
+% The selective input functionality of the |tikzinput| package assumes that the TIKZ
+% pictures are externalized into a standalone picture file, such as the one
+% Example~\ref{fig:tikzpic}.
+%
+% \begin{exfig}
+% \begin{verbatim}
+% \documentclass{standalone}
+% \usepackage{tikz}
+% \usetikzpackage{...}
+% \begin{document}
+% \begin{tikzpicture}
+% ...
+% \end{tikzpicture}
+% \end{document}
+% \end{verbatim}
+% \caption{A Standalone TIKZ Picture File}\label{fig:tikzpic}
+% \end{exfig}
+% \end{omgroup}
+% \end{omgroup}
+%
+% The |standalone| class is a minimal {\LaTeX} class that when loaded in a document that
+% uses the |standalone| package: the preamble and the |document| environment are
+% disregarded during loading, so they do not pose any problems. In effect, an |\input| of
+% the file in Figure~\ref{fig:tikzpic} only sees the |tikzpicture| environment, but the
+% file itself is standalone in the sense that we can run {\LaTeX} over it separately,
+% e.g. for generating an image file from it.
+%
+% This is exactly where the |tikzinput| package comes in: it supplies the
+% \DescribeMacro{\tikzinput}|\tikzinput| macro, which -- depending on the |image| option
+% -- either directly inputs the TIKZ picture (source) or tries to load an image file
+% generated from it.
+%
+% Concretely, if the |image| option is not set for the |tikzinput| package, then
+% |\tikzinput[|\meta{opt}|]{|\meta{file}|}| disregards the optional argument \meta{opt}
+% and inputs \meta{file}|.tex| via |\input|. If it is,
+% |\tikzinput[|\meta{opt}|]{|\meta{file}|}| expands to
+% |\includegraphics[|\meta{opt}|]{|\meta{file}|}|.
+%
+% \begin{omgroup}{Limitations}\label{sec:limitations}
+%
+% In this section we document known limitations. If you want to help alleviate them,
+% please feel free to contact the package author. Some of them are currently discussed in
+% the \sTeX GitHub repository~\cite{sTeX:github:on}.
+% \begin{compactenum}
+% \item none reported yet
+% \end{compactenum}
+% \end{omgroup}
+%
+% \StopEventually{\newpage\PrintIndex\newpage\PrintChanges\printbibliography}\newpage
+%
+% \begin{omgroup}[id=sec:impl]{Implementation}
+%
+% \begin{omgroup}{Package Options and Required Packages}
+%
+% We define a new switch \DescribeMacro{\iftikzinput@image}|\iftikzinput@image| and the
+% |image| option. Apart from that we accept all options that might come our
+% way.\ednote{MK: Actually we would have liked to pass all options to TIKZ, but that
+% does not work, since that is specific about its options.}
+% \begin{macrocode}
+%<*package>
+\newif\if@tikzinput@mh@\@tikzinput@mh@false
+\DeclareOption{mh}{\@tikzinput@mh@true}
+\newif\iftikzinput@image\tikzinput@imagefalse
+\DeclareOption{image}{\tikzinput@imagetrue}
+\DeclareOption*{}
+\ProcessOptions
+% \end{macrocode}
+% Next we require the packages we need, in the |image| case, we have to also provide
+% ``empty'' versions of some TIKZ macros and environments that do not get defined as the
+% |tikz| package is not loaded.
+% \begin{macrocode}
+\if@tikzinput@mh@\RequirePackage{tikzinput-mh}\fi
+\iftikzinput@image
+\RequirePackage{graphicx}
+\providecommand\usetikzlibrary[1]{}
+\else
+\RequirePackage{tikz}
+\RequirePackage{standalone}
+\fi
+% \end{macrocode}
+% \end{omgroup}
+%
+% \begin{omgroup}{Inputting Standalone TIKZ Pictures}
+%
+% \begin{macro}{\tikzinput}
+% Depending on the |image| option, we do the necessary things.
+% \begin{macrocode}
+\iftikzinput@image
+\newcommand\tikzinput[2][]{\includegraphics[#1]{#2}}
+\else
+\newcommand\tikzinput[2][]{\input{#2}}
+\fi
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\*tikzinput}
+% The variants we define in terms of |\tikzinput|.
+% \begin{macrocode}
+\newcommand\ctikzinput[2][]{\begin{center}\tikzinput{#2}\end{center}}
+%</package>
+% \end{macrocode}
+% \end{macro}
+% \end{omgroup}
+% \end{omgroup}
+%
+% \Finale
+% \endinput
+% Local Variables:
+% mode: doctex
+% TeX-master: t
+% End:
+
+% LocalWords: iffalse NeedsTeXFormat tikzinput tikzinput.dtx omdoc latexml texttt tikz
+% LocalWords: maketitle externalize newpage tableofcontents newpage omgroup behavior
+% LocalWords: graphicx externalized tikzpic exfig compactenum printbibliography impl
+% LocalWords: ltxml iftikzinput@image iftikzinput@image ednote newif etoolbox doctex
+% LocalWords: includegraphics providecommand usetikzlibrary ctikzinput