<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">%% This is file `dtk-extern.sty',
%%
%% LaTeX package for ``Die TeXnische Komoedie''.
%%
%% Copyright (C) 2016-
%% Rolf Niepraschk, Herbert Voss
%%
%% It 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 in
%%    http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.

\ProvidesFile{dtk-extern}%
  [2017/06/04 v0.06: dtk package for running external documents (HV)]

\RequirePackage{shellesc,filecontents,xkeyval,graphicx}

\newcounter{dtk@extern@runs}
\define@key{dtk}{compiler}[pdflatex]{\def\dtk@extern@compiler{#1}}
\define@key{dtk}{runsequence}[]{\def\dtk@extern@runsequence{#1}}
\define@key{dtk}{runs}[1]{\setcounter{dtk@extern@runs}{#1}}
\define@key{dtk}{grfOptions}[]{\def\dtk@extern@grfOptions{#1}}
\define@key{dtk}{lstOptions}[]{\def\dtk@extern@lstOptions{#1}}
\define@key{dtk}{docType}[latex]{\def\dtk@extern@docType{#1}}
\define@key{dtk}{caption}[]{\def\dtk@extern@caption{#1}}
\define@key{dtk}{label}[]{\def\dtk@extern@label{#1}}
\define@key{dtk}{pages}[1]{\def\dtk@extern@pages{#1}}
\define@boolkey{dtk}[dtk@extern@]{code}[true]{}
\define@boolkey{dtk}[dtk@extern@]{force}[true]{}
\define@boolkey{dtk}[dtk@extern@]{crop}[true]{}
\define@boolkey{dtk}[dtk@extern@]{biber}[true]{}
\define@boolkey{dtk}[dtk@extern@]{includegraphic}[true]{}
\define@boolkey{dtk}[dtk@extern@]{frame}[true]{}
\define@boolkey{dtk}[dtk@extern@]{float}[true]{}
\define@boolkey{dtk}[dtk@extern@]{cleanup}[true]{}

\def\ResetKeys{%
 \setkeys{dtk}{
  code=false,%          show Code
  crop=false,%		erzeugte PDF "croppen"
  compiler=pdflatex,%	zu verwendener Compiler
  grfOptions={},%	Optionen der einzubindenden Grafik
  lstOptions={},%	Optionen fÃ¼r das Listing
  includegraphic=true,% Grafik einbinden oder User Ã¼berlassen
  runs=1,%		Anzahl Compiler-DurchlÃ¤ufe
  runsequence={},%	Im Moment nicht aktiv
  biber=false,%		Biber laufen lassen?
  force=false,%		Compiler, auch wenn PDF existiert?
  frame=false,%		keinen Rahmen um Abbildung
  float=false,%		nicht als Gleitumgebung
  caption=,%	        keine Caption
  label=,%		kein Label
  pages=1,%		welche Seiten auszugeben sind
  docType=latex,%	LaTeX example Code
  cleanup=false,%	Hilfsdateien nicht lÃ¶schen
  }
}
\ResetKeys

{\catcode`\%=12 
 \gdef\perCent{%}
 \gdef\DoubleperCent{%%}
}

\newcommand\ExampleType[5]{%
   \@namedef{#1@initText}{linerange=#2-#3,includerangemarker=false}% text
   \@namedef{#1@initPreamble}{linerange=#4-#5,includerangemarker=false}% code
}

\ExampleType{latex}%               #1
  {begin\string{document\string}}%       #2
  {end\string{document\string}}%         #3
  {\perCent StartVisiblePreamble}% #4
  {\perCent StopVisiblePreamble}%  #5

\ExampleType{context}
  {\string\starttext}
  {\string\stoptext}
  {\perCent StartVisiblePreamble}
  {\perCent StopVisiblePreamble}

%%
%% [#1]: Optionen  #2: Dateiname
%%
\newenvironment{ErstelleGrafik}[2][]
  {\global\setkeys{dtk}{#1}%                   \begin
     \gdef\dtk@extern@dateiname{#2}%
   \begingroup
   \@nameuse{filecontents*}{#2.tex}
  }
  {\@nameuse{endfilecontents*}%         \end
   \endgroup
   \loop\ifnum\thedtk@extern@runs&gt;0
     \typeout{Run: \thedtk@extern@runs\space \dtk@extern@compiler\space\dtk@extern@dateiname}%
     \ShellEscape{\dtk@extern@compiler\space\dtk@extern@dateiname}%
     \addtocounter{dtk@extern@runs}{-1}%
   \repeat
   \ifdtk@extern@code
      \expandafter\edef\expandafter\dtk@lst@options@preamble\expandafter{%
        \@nameuse{\dtk@extern@docType @initPreamble},
        \dtk@extern@lstOptions,
        backgroundcolor=\noexpand\color{black!12}}%
      \expandafter\lstinputlisting\expandafter[\dtk@lst@options@preamble]{\dtk@extern@dateiname}
%     
      \expandafter\edef\expandafter\dtk@lst@options@text\expandafter{%
        \@nameuse{\dtk@extern@docType @initText},
        \dtk@extern@lstOptions,
        backgroundcolor=\noexpand\color{black!8}}%
      \typeout{\dtk@lst@options@text}
      \expandafter\lstinputlisting\expandafter[\dtk@lst@options@text]{\dtk@extern@dateiname}
   \fi
   \expandafter\IfFileExists\expandafter{\dtk@extern@dateiname.pdf}%
     {\ifdtk@extern@force
        \ifdtk@extern@biber
          \ShellEscape{biber  \dtk@extern@dateiname}%  NAch biber nochmal latex
          \ShellEscape{\dtk@extern@compiler\space\dtk@extern@dateiname}%
        \fi
        \ifdtk@extern@crop
          \ShellEscape{pdfcrop \dtk@extern@dateiname}%
          \ShellEscape{mv \dtk@extern@dateiname-crop.pdf \dtk@extern@dateiname.pdf}%
        \fi
      \fi
     }{}
   \ifdtk@extern@includegraphic
     \ifdtk@extern@float\begin{figure}[!htb]\centering\fi
     \ifdtk@extern@frame
       \expandafter\@for\expandafter\next\expandafter:\expandafter=\dtk@extern@pages\do{%
          \fbox{\expandafter\includegraphics\expandafter[\dtk@extern@grfOptions,page=\next]{\dtk@extern@dateiname}}%
              \hspace{5pt}}\hspace*{-5pt}
%   \fbox{\expandafter\includegraphics\expandafter[\dtk@extern@grfOptions]{\dtk@extern@dateiname}}%
     \else
       \expandafter\@for\expandafter\next\expandafter:\expandafter=\dtk@extern@pages\do{%
          \expandafter\includegraphics\expandafter[\dtk@extern@grfOptions,page=\next]{\dtk@extern@dateiname}%
              \hspace{5pt}}\hspace*{-5pt}
%       \expandafter\includegraphics\expandafter[\dtk@extern@grfOptions]{\dtk@extern@dateiname}%
     \fi
     \ifx\dtk@extern@caption\@empty\else\caption{\dtk@extern@caption}\fi
     \ifx\dtk@extern@label\@empty\else\label{\dtk@extern@label}\fi
     \ifdtk@extern@float\end{figure}\fi
   \fi
   \ifdtk@extern@cleanup
      \ShellEscape{rm \dtk@extern@dateiname.log}%
      \ShellEscape{rm \dtk@extern@dateiname.aux}%
      \ShellEscape{rm \dtk@extern@dateiname.toc}%
%      \ShellEscape{rm \dtk@extern@dateiname.log}%
   \fi
   \global\ResetKeys}
%
\let\externalDocument\ErstelleGrafik
\let\endexternalDocument\endErstelleGrafik
%%
\endinput
</pre></body></html>