diff options
author | Karl Berry <karl@freefriends.org> | 2022-04-27 19:38:45 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-04-27 19:38:45 +0000 |
commit | a1ed5651a5e3f5c5f92b9c4c21baea8538dfa77b (patch) | |
tree | 345e9e2b3052f3cd4d92283d535987938e77725c | |
parent | 0af0f41700900cdfd791389cb63c3b57ce4d957f (diff) |
hvextern (27apr22)
git-svn-id: svn://tug.org/texlive/trunk@63159 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/hvextern/Changes | 3 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/hvextern/README | 4 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/hvextern/hvextern.pdf | bin | 1041665 -> 1148759 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/hvextern/hvextern.tex | 134 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/hvextern/hvextern-context.cfg | 22 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/hvextern/hvextern-latex.cfg | 31 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/hvextern/hvextern-lua.cfg | 22 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/hvextern/hvextern-mp.cfg | 32 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/hvextern/hvextern-pl.cfg | 22 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/hvextern/hvextern-py.cfg | 27 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/hvextern/hvextern-tex.cfg | 30 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/hvextern/hvextern.sty | 208 |
12 files changed, 271 insertions, 264 deletions
diff --git a/Master/texmf-dist/doc/latex/hvextern/Changes b/Master/texmf-dist/doc/latex/hvextern/Changes index 3747ba251a0..5543cdd49fa 100644 --- a/Master/texmf-dist/doc/latex/hvextern/Changes +++ b/Master/texmf-dist/doc/latex/hvextern/Changes @@ -1,4 +1,7 @@ hvextern.sty ---------------- +v 0.20 2022-04-27 - use L3 for the comma separated lists + cleanup and runsequence + - move the config files into the main file v 0.19 2022-04-23 first CTAN version diff --git a/Master/texmf-dist/doc/latex/hvextern/README b/Master/texmf-dist/doc/latex/hvextern/README index c011f35cd2d..1c6052c9fd6 100644 --- a/Master/texmf-dist/doc/latex/hvextern/README +++ b/Master/texmf-dist/doc/latex/hvextern/README @@ -1,6 +1,6 @@ -This package allows to write code in tex, latex, Perl, Lua, PYthon, +This package allows to write code in tex, latex, Perl, Lua, Python, and MetaPost into external files, run that code and insert the -output as pdf or png image or text. Parts of the external code +output as pdf/png image or text. Parts of the external code can be listed in the document. The main LaTeX document must be run with the option --shell-escape diff --git a/Master/texmf-dist/doc/latex/hvextern/hvextern.pdf b/Master/texmf-dist/doc/latex/hvextern/hvextern.pdf Binary files differindex 99a251a6e88..bdefe9bd891 100644 --- a/Master/texmf-dist/doc/latex/hvextern/hvextern.pdf +++ b/Master/texmf-dist/doc/latex/hvextern/hvextern.pdf diff --git a/Master/texmf-dist/doc/latex/hvextern/hvextern.tex b/Master/texmf-dist/doc/latex/hvextern/hvextern.tex index 8acd4e841cb..50d93cef06f 100644 --- a/Master/texmf-dist/doc/latex/hvextern/hvextern.tex +++ b/Master/texmf-dist/doc/latex/hvextern/hvextern.tex @@ -11,6 +11,7 @@ \usepackage{listings} \lstset{basicstyle=\ttfamily\small,language=[LaTeX]TeX,breaklines} \usepackage{xcolor} +\usepackage{hyperref} \begin{document} \title{Writing, running and including the output of external documents from within a main \LaTeX\ document~--v. \hvexternFileversion} @@ -58,6 +59,15 @@ The purpose for this package is to show the output of documents which have to be a different preamble or a different engine or a complete different system, but integrating the output automatically in the main document.. +\bigskip +\noindent +\fbox{\begin{minipage}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax} +\emph{All} examples in this document are created on-the-fly while running this \LaTeX\ document +with \texttt{lualatex} with the \texttt{-\kern2pt-shell-escape} option. +\end{minipage}} + + + \section{First examples} \subsection{Without showing the code} @@ -137,7 +147,7 @@ The png image is created on the fly with the following arguments of \verb|exter The code which is declared as header and main can be marked by: \begin{Verbatim} -\extern@ExampleType{py} +\hv@extern@exampleType{py} {\NumChar StartVisibleMain} {\NumChar StopVisibleMain} {\NumChar StartVisiblePreamble} @@ -296,11 +306,11 @@ The marker for the code ranges which should be listed depend to the used program everything between \verb|%StartVisiblePreamble| and \verb|%StopVisiblePreamble| will be listed as preamble and in case of a \LaTeX\ source everything between - \verb|\begin{document}| and \verb|\end{document}| as body. The marker must be defined in an own - config file, e.g. \texttt{hv-extern-py.cfg}: + \verb|\begin{document}| and \verb|\end{document}| as body. The marker must be defined with an own +macro, e.g.: \begin{verbatim} -\extern@ExampleType{py} +\hv@extern@exampleType{py} {\NumChar StartVisibleMain} {\NumChar StopVisibleMain} {\NumChar StartVisiblePreamble} @@ -314,7 +324,7 @@ is pdflatex. The option \texttt{docType} selects the config file, which must be context, lua, pl, tex, latex, mp, and py. For Lua it is \begin{verbatim} -\extern@ExampleType{lua} +\hv@extern@exampleType{lua} {--StartVisibleMain} {--StopVisibleMain} {--StartVisiblePreamble} @@ -336,7 +346,7 @@ The deafault setting is always shown in brackets. The \texttt{progpath} should only in some rare cases needed. In general all used compilers will be found by the system. A given \texttt{progpath} -must be end with a slash, e.g. \texttt{./bin/} The option \texttt{runsequence} is currently not used. +must be end with a slash, e.g. \texttt{./bin/} %The option \texttt{runsequence} is currently not used. \begin{verbatim} \define@key{hv}{progpath}[]{\def\hv@extern@progpath{#1}} @@ -345,6 +355,54 @@ must be end with a slash, e.g. \texttt{./bin/} The option \texttt{runsequence} i \define@key{hv}{runs}[1]{\setcounter{hv@extern@runs}{#1}} \end{verbatim} +Instead of the optional arguments + \texttt{compiler}, \texttt{biber}, and \texttt{xindex} one can define an individual + command sequence by using the optional argument + \texttt{runsequence}. It must be comma separated list: + +\begin{verbatim} +runsequence={lualatex,biber,xindex -l de -c AU,lualatex,lualatex} +\end{verbatim} + +\begin{externalDocument}[ + grfOptions={width=0.30\linewidth}, + pages={1,3,5}, + frame, + runsequence={lualatex,biber,xindex -l de -c AU,lualatex,lualatex}, + showFilename, + verbose, + force, + cleanup={log,aux,toc,bbl,blg}, + code,docType=latex, + lstOptions={columns=fixed}]{voss} +\documentclass[paper=a5,parskip=half-,DIV=12,fontsize=12pt]{scrbook} +%StartVisiblePreamble +\usepackage[ngerman]{babel} +\usepackage{libertinus,hvindex} +\usepackage{makeidx}\makeindex +\usepackage{biblatex}\addbibresource{biblatex-examples.bib} +%StopVisiblePreamble +\usepackage{blindtext} +\begin{document} +Sort with xindex \verb|-l DE --config AU| +\blindtext +\Index{Österreich} \Index{Öresund} +\Index{Ostern} \Index{Ober} \Index{Oberin} +\Index{Österreich} \Index{Öresund} +\Index{Ödem} \Index{Oligarch} \Index{Oder} +\Index{Goldmann} +\printindex +\nocite{*}\printbibliography +\blindtext +\blinddocument + +\end{document} +\end{externalDocument} + + + + + \subsection{Grafik options} \begin{verbatim} \define@key{hv}{grfOptions}[]{\def\hv@extern@grfOptions{#1}} @@ -469,12 +527,12 @@ The color of the frame is set to the same values, hence not seen. The following \subsection{Type of the source code} The current version of \texttt{hvextern} supports code written as -\MP, \plainTeX, \LaTeX, \ConTeXt, and Python. Every type has its own config file which -defines the keywords for the linerange which should be printed for the preamble and -the body. For example the \texttt{latex} config file \texttt{hvextern-latex,cfg}: +\MP, \plainTeX, \LaTeX, \ConTeXt, and Python. Every type has its own keywords for the +linerange which should be printed for the preamble and +the body. For example the \texttt{latex} config is: \begin{verbatim} -\extern@ExampleType{latex}% for _all_LaTeX engines +\hv@extern@exampleType{latex}% for _all_LaTeX engines {\string\begin\string{document\string}}% {\string\end\string{document\string}}% {\perCent StartVisiblePreamble}% @@ -1000,6 +1058,7 @@ For a \LaTeX\ additional programs for bibliography, index, a.s.o. maybe needed. \define@boolkey{hv}[hv@extern@]{biber}[true]{} \define@boolkey{hv}[hv@extern@]{xindex}[true]{} \define@key{hv}{xindexOptions}[]{\def\hv@extern@xindexOptions{#1}} +\define@key{hv}{runsequence}[]{\def\hv@extern@runsequence{#1}} \end{verbatim} The \texttt{biber} run needs no additional options, but for \texttt{xindex} it maybe useful. @@ -1007,13 +1066,9 @@ The following examples uses \begin{verbatim} \begin{externalDocument}[ - compiler=lualatex, runs=2, - pages=2, - crop, - xindex, - xindexOptions={-l DE --config AU}, - mpwidth=0.6\linewidth, - usefancyvrb=false, + compiler=lualatex, runs=2, pages=2,crop, + xindex, xindexOptions={-l DE --config AU}, + mpwidth=0.6\linewidth, usefancyvrb=false, docType=latex, ... ]{voss} @@ -1073,6 +1128,48 @@ Sort with xindex \verb|-l DE --config AU| \end{externalDocument} +Instad of using the options \texttt{compiler}, \texttt{biber}, and \texttt{xindex} +one can also use only the optional argument \texttt{runsequence} to define an individuell +sequence of commands, e.g.: +\begin{verbatim} +runsequence={lualatex,biber,{xindex -l de -c AU},lualatex,lualatex} +\end{verbatim} + +\begin{externalDocument}[ + grfOptions={width=0.30\linewidth}, + pages={1,3,5}, + frame, + runsequence={lualatex,biber,xindex -l de -c AU,lualatex,lualatex}, + showFilename, + verbose, + force, + cleanup={log,aux,toc,bbl,blg}, + code,docType=latex, + lstOptions={columns=fixed}]{voss} +\documentclass[paper=a5,parskip=half-,DIV=12,fontsize=12pt]{scrbook} +%StartVisiblePreamble +\usepackage[ngerman]{babel} +\usepackage{libertinus,hvindex} +\usepackage{makeidx}\makeindex +\usepackage{biblatex}\addbibresource{biblatex-examples.bib} +%StopVisiblePreamble +\usepackage{blindtext} +\begin{document} +Sort with xindex \verb|-l DE --config AU| +\blindtext +\Index{Österreich} \Index{Öresund} +\Index{Ostern} \Index{Ober} \Index{Oberin} +\Index{Österreich} \Index{Öresund} +\Index{Ödem} \Index{Oligarch} \Index{Oder} +\Index{Goldmann} +\printindex +\nocite{*}\printbibliography +\blindtext +\blinddocument + +\end{document} +\end{externalDocument} + @@ -1301,12 +1398,13 @@ This is the start of the introduction. verbose=false, compiler=lualatex, showFilename, -% crop, + crop, force, code, docType=latex, ext=tex,]{voss} \documentclass{report} +\pagestyle{empty} %StartVisiblePreamble \usepackage{fontenc}\usepackage{libertinus} \usepackage{pst-all} diff --git a/Master/texmf-dist/tex/latex/hvextern/hvextern-context.cfg b/Master/texmf-dist/tex/latex/hvextern/hvextern-context.cfg deleted file mode 100644 index f45cc861537..00000000000 --- a/Master/texmf-dist/tex/latex/hvextern/hvextern-context.cfg +++ /dev/null @@ -1,22 +0,0 @@ -%% This is file `hvextern-ctx.cfg', -%% -%% Copyright (C) 2016-22 Herbert Voß hvoss@tug.org -%% -%% 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. - -\def\hvFileversion{0.01} -\ProvidesFile{hvextern-ctx}[2022/04/21 v\hvFileversion: running context (HV)] - -\extern@ExampleType{context} - {\string\starttext} - {\string\stoptext} - {\perCent StartVisiblePreamble} - {\perCent StopVisiblePreamble} - -\endinput diff --git a/Master/texmf-dist/tex/latex/hvextern/hvextern-latex.cfg b/Master/texmf-dist/tex/latex/hvextern/hvextern-latex.cfg deleted file mode 100644 index 8f186f9e58f..00000000000 --- a/Master/texmf-dist/tex/latex/hvextern/hvextern-latex.cfg +++ /dev/null @@ -1,31 +0,0 @@ -%% This is file `hvextern-mp.cfg', -%% -%% Copyright (C) 2016-22 Herbert Voß hvoss@tug.org -%% -%% 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. - -\def\hvFileversion{0.01} -\ProvidesFile{hvextern-latex}[2022/04/21 v\hvFileversion: running latex (HV)] - -\extern@ExampleType{latex}% - {\string\begin\string{document\string}}% - {\string\end\string{document\string}}% - {\perCent StartVisiblePreamble}% - {\perCent StopVisiblePreamble}% - -% only for the sequence latex->dvips->ps2pdf -\def\hv@extern@runLATEX#1#2#3#4{% path compiler file extension - \ifhv@extern@verbose \typeout{>>>> running #1#2 #3#4}\fi - \ShellEscape{#1#2\space #3#4}% - \ifhv@extern@verbose \typeout{>>>> running #1dvips #3}\fi - \ShellEscape{#1dvips\space #3.dvi}% - \ifhv@extern@verbose \typeout{>>>> running ps2pdf #3.ps}\fi - \ShellEscape{#1ps2pdf\space -dAutoRotatePages=/None\space -dALLOWPSTRANSPARENCY\space #3.ps}% -} -\endinput diff --git a/Master/texmf-dist/tex/latex/hvextern/hvextern-lua.cfg b/Master/texmf-dist/tex/latex/hvextern/hvextern-lua.cfg deleted file mode 100644 index 85a3ee6920f..00000000000 --- a/Master/texmf-dist/tex/latex/hvextern/hvextern-lua.cfg +++ /dev/null @@ -1,22 +0,0 @@ -%% This is file `hvextern-lua.cfg', -%% -%% Copyright (C) 2016-22 Herbert Voß hvoss@tug.org -%% -%% 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. - -\def\hvFileversion{0.01} -\ProvidesFile{hvextern-lua}[2022/04/23 v\hvFileversion: running Lua (HV)] - -\extern@ExampleType{lua} - {--StartVisibleMain} - {--StopVisibleMain} - {--StartVisiblePreamble} - {--StopVisiblePreamble} - -\endinput diff --git a/Master/texmf-dist/tex/latex/hvextern/hvextern-mp.cfg b/Master/texmf-dist/tex/latex/hvextern/hvextern-mp.cfg deleted file mode 100644 index 9e42167f9cd..00000000000 --- a/Master/texmf-dist/tex/latex/hvextern/hvextern-mp.cfg +++ /dev/null @@ -1,32 +0,0 @@ -%% This is file `hvextern-mp.cfg', -%% -%% Copyright (C) 2016-22 Herbert Voß hvoss@tug.org -%% -%% 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. - -\def\hvFileversion{0.01} -\ProvidesFile{hvextern-mp}[2022/04/21 v\hvFileversion: running MetaPost (HV)] - -\extern@ExampleType{mp} - {beginfig(1)} - {endfig;} - {\perCent StartVisiblePreamble} - {\perCent StopVisiblePreamble} - -\def\hv@extern@runMP#1#2#3#4{% path compiler file extension - \ifhv@extern@verbose \typeout{>>>> running #1#2 #3#4}\fi - \ShellEscape{#1#2\space -tex=tex\space #3#4}% - \ifhv@extern@verbose \typeout{>>>> running #1tex #3}\fi - \ShellEscape{#1tex\space "\string\input\space epsf\string\relax\string\nopagenumbers\string\epsfbox{#3.1}\string\bye"}% - \ifhv@extern@verbose \typeout{>>>> running #1dvips #3}\fi - \ShellEscape{#1dvips\space -j\space -E\space -o\space #3.eps\space epsf.dvi}% - \ifhv@extern@verbose \typeout{>>>> running #1epstopdf #3}\fi - \ShellEscape{#1epstopdf\space #3.eps}% -} -\endinput diff --git a/Master/texmf-dist/tex/latex/hvextern/hvextern-pl.cfg b/Master/texmf-dist/tex/latex/hvextern/hvextern-pl.cfg deleted file mode 100644 index 656f2d81776..00000000000 --- a/Master/texmf-dist/tex/latex/hvextern/hvextern-pl.cfg +++ /dev/null @@ -1,22 +0,0 @@ -%% This is file `hvextern-pl.cfg', -%% -%% Copyright (C) 2016-22 Herbert Voß hvoss@tug.org -%% -%% 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. - -\def\hvFileversion{0.01} -\ProvidesFile{hvextern-pl}[2022/04/22 v\hvFileversion: running Perl (HV)] - -\extern@ExampleType{pl} - {\NumChar StartVisibleMain} - {\NumChar StopVisibleMain} - {\NumChar StartVisiblePreamble} - {\NumChar StopVisiblePreamble} - -\endinput diff --git a/Master/texmf-dist/tex/latex/hvextern/hvextern-py.cfg b/Master/texmf-dist/tex/latex/hvextern/hvextern-py.cfg deleted file mode 100644 index eaf51f8212a..00000000000 --- a/Master/texmf-dist/tex/latex/hvextern/hvextern-py.cfg +++ /dev/null @@ -1,27 +0,0 @@ -%% This is file `hvextern-py.cfg', -%% -%% Copyright (C) 2016-22 Herbert Voß hvoss@tug.org -%% -%% 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. - -\def\hvFileversion{0.01} -\ProvidesFile{hvextern-py}[2022/04/22 v\hvFileversion: running Python (HV)] - -\extern@ExampleType{py} - {\NumChar StartVisibleMain} - {\NumChar StopVisibleMain} - {\NumChar StartVisiblePreamble} - {\NumChar StopVisiblePreamble} - -%\def\hv@extern@runPYTHON#1#2#3#4{% path compiler file extension -% \ifhv@extern@verbose \typeout{>>>> running #1#2 #3#4}\fi -% \ShellEscape{#1python2\space #3#4}% for special version -%} - -\endinput diff --git a/Master/texmf-dist/tex/latex/hvextern/hvextern-tex.cfg b/Master/texmf-dist/tex/latex/hvextern/hvextern-tex.cfg deleted file mode 100644 index 2baf3552f8b..00000000000 --- a/Master/texmf-dist/tex/latex/hvextern/hvextern-tex.cfg +++ /dev/null @@ -1,30 +0,0 @@ -%% This is file `hvextern-mp.cfg', -%% -%% Copyright (C) 2016-22 Herbert Voß hvoss@tug.org -%% -%% 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. - -\def\hvFileversion{0.01} -\ProvidesFile{hvextern-latex}[2022/04/21 v\hvFileversion: running latex (HV)] - -\extern@ExampleType{tex} - {\perCent StartBody} - {\string\bye} - {\perCent StartVisiblePreamble} - {\perCent StopVisiblePreamble} - -\def\hv@extern@runTEX#1#2#3#4{% path compiler file extension - \ifhv@extern@verbose \typeout{>>>> running #1#2 #3#4}\fi - \ShellEscape{#1tex\space #3#4}% - \ifhv@extern@verbose \typeout{>>>> running #1dvips #3}\fi - \ShellEscape{#1dvips\space #3.dvi}% - \ifhv@extern@verbose \typeout{>>>> running ps2pdf #3.ps}\fi - \ShellEscape{#1ps2pdf\space -dAutoRotatePages=/None\space -dALLOWPSTRANSPARENCY\space #3.ps}% -} -\endinput diff --git a/Master/texmf-dist/tex/latex/hvextern/hvextern.sty b/Master/texmf-dist/tex/latex/hvextern/hvextern.sty index 201f4ef7b11..9e3fbea8c0e 100644 --- a/Master/texmf-dist/tex/latex/hvextern/hvextern.sty +++ b/Master/texmf-dist/tex/latex/hvextern/hvextern.sty @@ -11,11 +11,11 @@ %% and version 1.3c or later is part of all distributions of LaTeX %% version 2005/12/01 or later. -\def\hvexternFileversion{0.19} -\ProvidesFile{hvextern}[2022/04/23 v\hvexternFileversion: package for running external documents (HV)] +\def\hvexternFileversion{0.20} +\ProvidesFile{hvextern}[2022/04/27 v\hvexternFileversion: package for running external documents (HV)] \RequirePackage{shellesc,xkeyval,graphicx,marginnote,fancyvrb,tikz,listings,ifplatform} -\RequirePackage{tcolorbox} +\RequirePackage{tcolorbox,xparse} \tcbuselibrary{skins,breakable} \ifwindows @@ -29,8 +29,8 @@ \newcounter{hv@extern@runs} \newcounter{@@@runs} \newsavebox\hv@extern@box -\newlength\LineWidth -\AtBeginDocument{\setlength\LineWidth{\dimexpr\linewidth-2\fboxsep-2\fboxrule}} +\newlength\hv@LineWidth +\AtBeginDocument{\setlength\hv@LineWidth{\dimexpr\linewidth-2\fboxsep-2\fboxrule}} \newlength\hv@extern@mpwidth \setlength\hv@extern@mpwidth{\z@} \define@key{hv}{progpath}{\def\hv@extern@progpath{#1}} @@ -49,6 +49,7 @@ \define@key{hv}{cropmargin}[2]{\def\hv@extern@cropmargin{#1 }} \define@key{hv}{mpwidth}[0pt]{\setlength\hv@extern@mpwidth{#1}} \define@key{hv}{ext}[tex]{\def\hv@extern@ext{.#1}} +\define@boolkey{hv}[hv@extern@]{redirect}[true]{} \define@boolkey{hv}[hv@extern@]{usefancyvrb}[true]{} \define@boolkey{hv}[hv@extern@]{showFilename}[true]{} \define@boolkey{hv}[hv@extern@]{code}[true]{} @@ -93,6 +94,7 @@ code=false,% show Code crop=false,% erzeugte PDF "croppen" compiler=pdflatex,% zu verwendener Compiler + redirect=false,% write output into a file *.txt grfOptions={},% Optionen der einzubindenden Grafik lstOptions={},% Optionen für das Listing BGpreamble=black!12,% Backgroundcolor for preamble @@ -134,20 +136,19 @@ \gdef\DoubleNumChar{##} } -\def\run@hv@extern@cleanup#1{\expandafter\run@hv@extern@cleanup@i#1,\@nil} -\def\run@hv@extern@cleanup@i#1,#2\@nil{% - \def\hv@next{}% - \ifx\relax#1\relax - \else - \hv@typeout{>>>> Delete file \hv@extern@ExamplesDir\hvExternDateiname.#1}% - \ShellEscape{\hv@rm \hv@extern@ExamplesDir\hvExternDateiname.#1}% - \ifx\relax#2\relax\else - \def\hv@next{\run@hv@extern@cleanup@i#2,\@nil}% - \fi - \fi - \hv@next -} - +\ExplSyntaxOn +\NewDocumentCommand\run@hv@extern@cleanup{ m } + { + \clist_map_inline:nn {#1}{\ShellEscape{\hv@rm \hv@extern@ExamplesDir\hvExternDateiname.##1}} + } +\NewDocumentCommand\run@hv@extern@sequenceList{ m } + { + \clist_map_inline:nn {#1}{% + \ShellEscape{\hv@extern@progpath##1\space\hvExternDateiname} + %\hv@typeout{>>>> sequencerun: ##1} + } + } +\ExplSyntaxOff \lstset{belowskip=0pt,aboveskip=0pt}% global \tcbset{breakable,left=2pt,right=2pt,top=2pt,bottom=2pt,boxsep=0pt} @@ -162,25 +163,109 @@ \newcounter{hv@example@counter} -\newcommand\extern@ExampleType[5]{% +\newcommand\hv@extern@ExampleType[5]{% \@namedef{#1@initTextFancy}{\edef\FancyVerbStartString{#2}\edef\FancyVerbStopString{#3}}% text \@namedef{#1@initPreambleFancy}{\edef\FancyVerbStartString{#4}\edef\FancyVerbStopString{#5}}% code \@namedef{#1@initText}{linerange={#2}-{#3},includerangemarker=false}% text \@namedef{#1@initPreamble}{linerange={#4}-{#5},includerangemarker=false}% code }% ^^to prevent problems with lua comments -\input{hvextern-mp.cfg} -\input{hvextern-tex.cfg} -\input{hvextern-latex.cfg} -\input{hvextern-context.cfg} -\input{hvextern-py.cfg} -\input{hvextern-pl.cfg} -\input{hvextern-lua.cfg} +%%------------------ the config part -------------------- +%\input{hvextern-mp.cfg} +%---- MP +\hv@extern@ExampleType{mp} + {beginfig(1)} + {endfig;} + {\perCent StartVisiblePreamble} + {\perCent StopVisiblePreamble} + +\def\hv@extern@runMP#1#2#3#4{% path compiler file extension + \hv@typeout{>>>> running #1#2 #3#4}% + \ShellEscape{#1#2\space -tex=tex\space #3#4}% + \hv@typeout{>>>> running #1tex #3}% + \ShellEscape{#1tex\space "\string\input\space epsf\string\relax\string\nopagenumbers\string\epsfbox{#3.1}\string\bye"}% + \hv@typeout{>>>> running #1dvips #3}% + \ShellEscape{#1dvips\space -j\space -E\space -o\space #3.eps\space epsf.dvi}% + \hv@typeout{>>>> running #1epstopdf #3}% + \ShellEscape{#1epstopdf\space #3.eps}% +} + +%---- TeX +%\input{hvextern-tex.cfg} +\hv@extern@ExampleType{tex} + {\perCent StartBody} + {\string\bye} + {\perCent StartVisiblePreamble} + {\perCent StopVisiblePreamble} + +\def\hv@extern@runTEX#1#2#3#4{% path compiler file extension + \hv@typeout{>>>> running #1#2 #3#4}% + \ShellEscape{#1tex\space #3#4}% + \hv@typeout{>>>> running #1dvips #3}% + \ShellEscape{#1dvips\space #3.dvi}% + \hv@typeout{>>>> running ps2pdf #3.ps}% + \ShellEscape{#1ps2pdf\space -dAutoRotatePages=/None\space -dALLOWPSTRANSPARENCY\space #3.ps}% +} + +%---- LaTeX +%\input{hvextern-latex.cfg} +\hv@extern@ExampleType{latex}% + {\string\begin\string{document\string}}% + {\string\end\string{document\string}}% + {\perCent StartVisiblePreamble}% + {\perCent StopVisiblePreamble}% + +% only for the sequence latex->dvips->ps2pdf +\def\hv@extern@runLATEX#1#2#3#4{% path-compiler-file-extension + \hv@typeout{>>>> running #1#2 #3#4}% + \ShellEscape{#1#2\space #3#4}% + \hv@typeout{>>>> running #1dvips #3}% + \ShellEscape{#1dvips\space #3.dvi}% + \hv@typeout{>>>> running ps2pdf #3.ps}% + \ShellEscape{#1ps2pdf\space -dAutoRotatePages=/None\space -dALLOWPSTRANSPARENCY\space #3.ps}% +} + +%---- ConTeXt +%\input{hvextern-context.cfg} +\hv@extern@ExampleType{context} + {\string\starttext} + {\string\stoptext} + {\perCent StartVisiblePreamble} + {\perCent StopVisiblePreamble} + +%---- Python +%\input{hvextern-py.cfg} +\hv@extern@ExampleType{py} + {\NumChar StartVisibleMain} + {\NumChar StopVisibleMain} + {\NumChar StartVisiblePreamble} + {\NumChar StopVisiblePreamble} + + +%---- Perl +%\input{hvextern-pl.cfg} +\hv@extern@ExampleType{pl} + {\NumChar StartVisibleMain} + {\NumChar StopVisibleMain} + {\NumChar StartVisiblePreamble} + {\NumChar StopVisiblePreamble} + + +%---- Lua +%\input{hvextern-lua.cfg} +\hv@extern@ExampleType{lua} + {--StartVisibleMain} + {--StopVisibleMain} + {--StartVisiblePreamble} + {--StopVisiblePreamble} + + +%%%--------------------------------- end config part ------------------ %% %% [#1]: Optionen #2: Dateiname %% -\newenvironment{ErstelleGrafik}[2][]{% +\newenvironment{externalDocument}[2][]{% \xdef\hvExternDateiname{#2-\arabic{hv@example@counter}}% \setkeys{hv}{#1}% \begin \expandafter\IfFileExists\expandafter{\hv@extern@ExamplesDir\hvExternDateiname.pdf}{}{% @@ -196,33 +281,41 @@ \global\stepcounter{hv@example@counter}% \endgroup \ifhv@extern@force - \hv@typeout{>>> force=true: running \hv@extern@progpath\hv@extern@compiler~ \hvExternDateiname\hv@extern@ext ...}% - \setcounter{@@@runs}{\value{hv@extern@runs}}% - \loop\ifnum\the@@@runs > 0\relax - \ifcase\hv@extern@compilerNo \relax % we have metapost - \hv@typeout{>>>> running mpost \hvExternDateiname\hv@extern@ext}% - \hv@extern@runMP{\hv@extern@progpath}{\hv@extern@compiler}{\hvExternDateiname}{\hv@extern@ext}% - \or %1 - \hv@typeout{>>>> running tex \hvExternDateiname\hv@extern@ext}% - \hv@extern@runTEX{\hv@extern@progpath}{\hv@extern@compiler}{\hvExternDateiname}{\hv@extern@ext}% - \or %2 - \hv@typeout{>>>> running \hv@extern@compiler~ \hvExternDateiname\hv@extern@ext}% - \hv@extern@runLATEX{\hv@extern@progpath}{\hv@extern@compiler}{\hvExternDateiname}{\hv@extern@ext}% - \else - \hv@typeout{>>>> running \hv@extern@compiler~ \hvExternDateiname\hv@extern@ext}% - \ShellEscape{\hv@extern@progpath\hv@extern@compiler\space\hvExternDateiname\hv@extern@ext}% + \ifx\hv@extern@runsequence\@empty + \hv@typeout{>>>> force=true: running \hv@extern@progpath\hv@extern@compiler~ \hvExternDateiname\hv@extern@ext ...}% + \setcounter{@@@runs}{\value{hv@extern@runs}}% + \loop\ifnum\the@@@runs > 0\relax + \ifcase\hv@extern@compilerNo \relax % we have metapost + \hv@typeout{>>>> running mpost \hvExternDateiname\hv@extern@ext}% + \hv@extern@runMP{\hv@extern@progpath}{\hv@extern@compiler}{\hvExternDateiname}{\hv@extern@ext}% + \or %1 + \hv@typeout{>>>> running tex \hvExternDateiname\hv@extern@ext}% + \hv@extern@runTEX{\hv@extern@progpath}{\hv@extern@compiler}{\hvExternDateiname}{\hv@extern@ext}% + \or %2 + \hv@typeout{>>>> running \hv@extern@compiler~ \hvExternDateiname\hv@extern@ext}% + \hv@extern@runLATEX{\hv@extern@progpath}{\hv@extern@compiler}{\hvExternDateiname}{\hv@extern@ext}% + \else + \hv@typeout{>>>> running \hv@extern@compiler~ \hvExternDateiname\hv@extern@ext}% + \ifhv@extern@redirect + \ShellEscape{\hv@extern@progpath\hv@extern@compiler\space\hvExternDateiname\hv@extern@ext\space > \hvExternDateiname.txt}% + \else + \ShellEscape{\hv@extern@progpath\hv@extern@compiler\space\hvExternDateiname\hv@extern@ext}% + \fi + \fi + \addtocounter{@@@runs}{-1}% + \repeat + \hv@typeout{>>> ... done}% + \ifhv@extern@biber + \ShellEscape{biber \hvExternDateiname}% NAch biber nochmal latex + \ShellEscape{\hv@extern@progpath\hv@extern@compiler\space\hvExternDateiname}% \fi - \addtocounter{@@@runs}{-1}% - \repeat - \hv@typeout{>>> ... done}% - \ifhv@extern@biber - \ShellEscape{biber \hvExternDateiname}% NAch biber nochmal latex - \ShellEscape{\hv@extern@progpath\hv@extern@compiler\space\hvExternDateiname}% - \fi - \ifhv@extern@xindex - \ShellEscape{xindex \hv@extern@xindexOptions\space \hvExternDateiname.idx}% NAch xindex nochmal latex - \ShellEscape{\hv@extern@progpath\hv@extern@compiler\space\hvExternDateiname}% - \fi + \ifhv@extern@xindex + \ShellEscape{xindex \hv@extern@xindexOptions\space \hvExternDateiname.idx}% NAch xindex nochmal latex + \ShellEscape{\hv@extern@progpath\hv@extern@compiler\space\hvExternDateiname}% + \fi + \else + \expandafter\run@hv@extern@sequenceList\expandafter{\hv@extern@runsequence}% + \fi \ifhv@extern@crop \ShellEscape{pdfcrop --margins \hv@extern@cropmargin \hvExternDateiname}% \ShellEscape{\hv@move \hvExternDateiname-crop.pdf \hvExternDateiname.pdf}% @@ -302,7 +395,8 @@ \hspace{5pt}}\hspace*{-5pt}% \else \expandafter\@for\expandafter\next\expandafter:\expandafter=\hv@extern@pages\do{% - \expandafter\includegraphics\expandafter[\hv@extern@grfOptions,page=\next]{\hv@extern@ExamplesDir\hvExternDateiname}% + \expandafter\includegraphics\expandafter[\hv@extern@grfOptions,page=\next]% + {\hv@extern@ExamplesDir\hvExternDateiname}% \hspace{5pt}}\hspace*{-5pt}% \fi \ifx\hv@extern@caption\@empty\else\caption{\hv@extern@caption}\fi @@ -322,11 +416,9 @@ \noindent\VerbatimInput{\hv@extern@ExamplesDir\hvExternDateiname.txt} \fi \fi - \ifhv@extern@force\run@hv@extern@cleanup{\hv@extern@cleanup}\fi% cleanup + \ifhv@extern@force\expandafter\run@hv@extern@cleanup\expandafter{\hv@extern@cleanup}\fi% cleanup } \stepcounter{hv@example@counter}% % -\let\externalDocument\ErstelleGrafik -\let\endexternalDocument\endErstelleGrafik %% \endinput |