summaryrefslogtreecommitdiff
path: root/macros/latex/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib')
-rw-r--r--macros/latex/contrib/hvextern/Changes4
-rw-r--r--macros/latex/contrib/hvextern/doc/hvextern.pdfbin1203772 -> 1203306 bytes
-rw-r--r--macros/latex/contrib/hvextern/doc/hvextern.tex226
-rw-r--r--macros/latex/contrib/hvextern/latex/hvextern.sty138
4 files changed, 240 insertions, 128 deletions
diff --git a/macros/latex/contrib/hvextern/Changes b/macros/latex/contrib/hvextern/Changes
index 964577b7fa..c83eea6c1f 100644
--- a/macros/latex/contrib/hvextern/Changes
+++ b/macros/latex/contrib/hvextern/Changes
@@ -1,5 +1,9 @@
hvextern.sty ----------------
+v 0.25 2022-05-19 - added framesep keyword
+ - added keywords for vertical space
+ - added keyword textOptions for reading text output
+ - use \hv@marginpar instead of \marginpar/\marginnote
v 0.24 2022-05-11 - fix introduced bug for \hv@rm
- added tcolorbox support for \runExtCmd
. added keywords pagesep and mpsep
diff --git a/macros/latex/contrib/hvextern/doc/hvextern.pdf b/macros/latex/contrib/hvextern/doc/hvextern.pdf
index 60f1d77645..b472862835 100644
--- a/macros/latex/contrib/hvextern/doc/hvextern.pdf
+++ b/macros/latex/contrib/hvextern/doc/hvextern.pdf
Binary files differ
diff --git a/macros/latex/contrib/hvextern/doc/hvextern.tex b/macros/latex/contrib/hvextern/doc/hvextern.tex
index ecc62a121f..a170457a7d 100644
--- a/macros/latex/contrib/hvextern/doc/hvextern.tex
+++ b/macros/latex/contrib/hvextern/doc/hvextern.tex
@@ -23,12 +23,12 @@
\begin{document}
\title{Writing, running and including the output of external documents
-from within a main \LaTeX\ document~--v. \hvexternFileversion}
-\author{Herbert Voß\thanks{herbert@dante.de}}
+from within a main\newline \LaTeX\ document~--v. \hvexternFileversion}
+\author{Herbert Voß \url{herbert@dante.de}}
\maketitle
\tableofcontents
-\newpage
+%\newpage
\setkeys{hv}{moveToExampleDir,ExampleDir=Examples,showFilename,verbose}
\section{Syntax}
@@ -37,6 +37,9 @@ from within a main \LaTeX\ document~--v. \hvexternFileversion}
\usepackage{hvextern}
\end{verbatim}
+\addtocontents{toc}{\protect\enlargethispage{2ex}}
+
+
\begin{sloppypar}
This package allows to write external \MP, \TeX, \ConTeXt, \LaTeX, \LuaTeX, \LuaLaTeX, \XeTeX, \XeLaTeX, Lua, Perl, Java and/or Python
source code, which will then be run via \texttt{shell escape} to create a PDF oder text output to include
@@ -144,7 +147,6 @@ The \ttIndex{png} image is created on the fly with the following arguments of \
\begin{Verbatim}
\begin{externalDocument}[
compiler=python3,
- showFilename,
code,
ext=py,
docType=py,
@@ -171,7 +173,6 @@ catagory, which is done internally by the package. The complete definition of th
\begin{Verbatim}
\begin{externalDocument}[
compiler=python3,
- showFilename,
code,
ext=py,
force=false,
@@ -225,7 +226,6 @@ line in the above code shows how it can be done with Python.
compiler=python3,
progpath=/usr/local/bin/,
force=false,
- showFilename,
runs=1,
code,
ext=py,
@@ -269,11 +269,9 @@ image.save(imageName+".png", "PNG")
-
-
\begin{externalDocument}[grfOptions={width=0.95\linewidth},
compiler=xelatex,code,mpwidth=0.6\linewidth,
- crop,cleanup,force=false,usefancyvrb=false,ext=tex]{voss}
+ crop,cleanup,force=false,usefancyvrb=false,ext=tex,showFilename=false]{voss}
\documentclass{article}
%StartVisiblePreamble
\usepackage{tikz}
@@ -298,6 +296,7 @@ image.save(imageName+".png", "PNG")
\end{externalDocument}
+
\section{Setting marker in the source}
The marker for the code ranges which should be listed depend to the used programming language:
@@ -379,9 +378,10 @@ runsequence={lualatex,biber,xindex -l de -c AU,lualatex,lualatex}
\begin{externalDocument}[
grfOptions={width=0.30\linewidth},
pages={1,3,5},
+ pagesep=2pt,
frame,
runsequence={lualatex,biber,xindex -l de -c AU,lualatex,lualatex},
- showFilename,
+ ,
verbose,
force=false,
cleanup={log,aux,toc,bbl,blg},
@@ -412,6 +412,9 @@ Sort with xindex \verb|-l DE --config AU|
\end{externalDocument}
+
+
+
The following \Java-program creates the Mandelbrot set as png image. The valid setting for
the environment \Lenv{externalDocument} is:
@@ -489,6 +492,8 @@ public class Main {
%$
+
+
\subsection{Grafik options}
\begin{verbatim}
\define@key{hv}{grfOptions}[]{\def\hv@extern@grfOptions{#1}}
@@ -524,6 +529,10 @@ the follwing example.
\end{externalDocument}
+
+\newpage%%%%%%%%%%%
+
+
\subsection{Listings options}
\begin{verbatim}
@@ -563,6 +572,8 @@ to \Lcs{VerbatimInput}. The following example uses
\end{document}
\end{externalDocument}
+
+
\subsection{Background color}
There are different colors for the preamble and body listing: the backgrund and frame color.
@@ -644,78 +655,24 @@ If a source needs more than running the defined compiler, it must be defined by
The type of the source code can be different to the compiler, e.g. source \Lkeyval{latex},
but compiler \Lkeyval{lualatex}.
-
-\subsection{Output as floating object with caption and label}
-
-By default the images are not inserted as a float. This can be changed by
-the keyword \Lkeyword{float}, a caption and a label are optional. The float type is always
-\Lenv{figure}.
-
-\begin{verbatim}
-\define@boolkey{hv}[hv@extern@]{float}[true]{}
-\define@key{hv}{caption}[]{\def\hv@extern@caption{#1}}
-\define@key{hv}{label}[]{\def\hv@extern@label{#1}}
-\end{verbatim}
-
-The image Figure~\ref{img:cox} shows an example for a floting object.
-
-\begin{externalDocument}[
- grfOptions={width=\linewidth},
- lstOptions={fontsize=\small,fontfamily=tt},
-% lstOptions={basicstyle=\small\ttfamily},
- compiler=lualatex,
- BGpreamble=red!10, BOpreamble=red,
- BGbody=blue!8, BObody=blue,
- code,
-% mpwidth=0.6\linewidth,
- crop,
- cleanup,
- force=false,
- usefancyvrb,
- float,
- caption={An example for Coxeter images},
- label=img:cox,
- docType=latex]{voss}
-\RequirePackage{pdfmanagement-testphase}
-\DeclareDocumentMetadata{}
-\documentclass{article}
-%StartVisiblePreamble
-\usepackage{pst-coxeterp}
-%StopVisiblePreamble
-\pagestyle{empty}
-\begin{document}
-\begin{pspicture}(-1,-1)(1,1)\Simplex[dimension=2]\end{pspicture}
-%
-\begin{pspicture}(-1,-1)(1,1)\Simplex[dimension=3]\end{pspicture}
-%
-\begin{pspicture}(-1,-1)(1,1)\Simplex[dimension=5]\end{pspicture}
-%
-\begin{pspicture}(-1,-1)(1,1)\Simplex[dimension=7]\end{pspicture}
-%
-% ------------------------------------
-% Only some text to show the pagebreak
-% ------------------------------------
-\end{document}
-\end{externalDocument}
-
-
-
-
\subsection{Output more than one page}
The pages which should be printed can be defined by
\begin{verbatim}
\define@key{hv}{pages}[1]{\def\hv@extern@pages{#1}}
+\define@key{hv}{pagesep}[1em]{\hv@extern@pagesep=#1}
\define@boolkey{hv}[hv@extern@]{frame}[true]{}
\end{verbatim}
With \Lkeyword{frame} the pages can be framed (internally by \Lcs{fbox}).
It is leaved to the user to choose the correct image width for the pages.
+The separation between the pages is defined by the length \Lkeyword{pagesep}.
The following example uses:
\begin{verbatim}
pages={1,2,3},
+ pagesep=2pt,
grfOptions={width=0.3\linewidth},
compiler=lualatex, runs=2, % for the TOC
frame,
@@ -723,6 +680,7 @@ The following example uses:
\begin{externalDocument}[
pages={1,2,3},
+ pagesep=2pt,
grfOptions={width=0.3\linewidth},
% lstOptions={fontsize=\small,fontfamily=tt},
compiler=lualatex, runs=2,
@@ -732,7 +690,7 @@ The following example uses:
% mpwidth=0.6\linewidth,
% crop,
cleanup,
- force=false,
+ force=true,
frame,
% usefancyvrb,
% float,
@@ -757,6 +715,61 @@ The following example uses:
+
+\subsection{Output as floating object with caption and label}
+
+By default the images are not inserted as a float. This can be changed by
+the keyword \Lkeyword{float}, a caption and a label are optional. The float type is always
+\Lenv{figure}.
+
+\begin{verbatim}
+\define@boolkey{hv}[hv@extern@]{float}[true]{}
+\define@key{hv}{floatsetting}[]{\def\hv@extern@floatsetting{#1}}
+\define@key{hv}{caption}[]{\def\hv@extern@caption{#1}}
+\define@key{hv}{label}[]{\def\hv@extern@label{#1}}
+\end{verbatim}
+
+The image Figure~\ref{img:cox} shows an example for a floating object, which uses the floatsetting \verb|!htb|,
+which is the default. Using a caption and a label are optional.
+
+\begin{externalDocument}[
+ grfOptions={width=\linewidth},
+ lstOptions={fontsize=\small,fontfamily=tt},
+% lstOptions={basicstyle=\small\ttfamily},
+ compiler=lualatex,
+ BGpreamble=red!10, BOpreamble=red,
+ BGbody=blue!8, BObody=blue,
+ code,
+% mpwidth=0.6\linewidth,
+ crop,
+ cleanup,
+ force=true,
+ usefancyvrb,
+ float,
+ floatsetting=!ht,
+ caption={An example for Coxeter images},
+ label=img:cox,
+ docType=latex]{voss}
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{}
+\documentclass{article}
+%StartVisiblePreamble
+\usepackage{pst-coxeterp}
+%StopVisiblePreamble
+\pagestyle{empty}
+\begin{document}
+\begin{pspicture}(-1,-1)(1,1)\Simplex[dimension=2]\end{pspicture}
+\begin{pspicture}(-1,-1)(1,1)\Simplex[dimension=3]\end{pspicture}
+\begin{pspicture}(-1,-1)(1,1)\Simplex[dimension=5]\end{pspicture}
+\begin{pspicture}(-1,-1)(1,1)\Simplex[dimension=7]\end{pspicture}
+\end{document}
+\end{externalDocument}
+
+
+
+%\clearpage%%%%%%%%%%%%%%%%%
+
+
\subsection{Cropping the PDF}
Instead of using the \Index{documentclass} \Lclass{standalone}, which already crops the created PDF,
one can use the optional argument \Lkeyword{crop}.
@@ -774,6 +787,7 @@ The follwoing example was created with
\begin{verbatim}
pages={1,2,3},
+ pagesep=2pt,
grfOptions={width=0.3\linewidth},
compiler=lualatex, runs=2, % for the TOC
frame,
@@ -782,6 +796,7 @@ The follwoing example was created with
\begin{externalDocument}[
pages={1,2,3},
+ pagesep=2pt,
grfOptions={width=0.3\linewidth},
% lstOptions={fontsize=\small,fontfamily=tt},
compiler=lualatex, runs=2,
@@ -838,17 +853,18 @@ or \Lkeyval{b}.
%\define@key{hv}{align}[\centering]{\def\hv@extern@align{#1}}
%\end{verbatim}
-\subsubsection{the default}
-
+%\textbf{the default}
+%
\begin{verbatim}
- align=\centering,
+ align=\centering, % default
\end{verbatim}
-
+%
\begin{externalDocument}[
compiler=lualatex, runs=2,
BGpreamble=red!10, BOpreamble=red,
BGbody=blue!8, BObody=blue,
code,
+ showFilename=false,
crop,
cleanup,
force=false,
@@ -860,7 +876,7 @@ or \Lkeyval{b}.
\end{document}
\end{externalDocument}
-\subsubsection{Left aligned}
+%\textbf{Left aligned}
\begin{verbatim}
align=\raggedright,
@@ -871,6 +887,7 @@ or \Lkeyval{b}.
compiler=lualatex, runs=2,
BGpreamble=red!10, BOpreamble=red,
BGbody=blue!8, BObody=blue,
+ showFilename=false,
code,
crop,
cleanup,
@@ -883,7 +900,7 @@ or \Lkeyval{b}.
\end{document}
\end{externalDocument}
-\subsubsection{Right aligned}
+%\textbf{Right aligned}
\begin{verbatim}
align=\raggedleft,
@@ -896,6 +913,7 @@ or \Lkeyval{b}.
BGpreamble=red!10, BOpreamble=red,
BGbody=blue!8, BObody=blue,
code,
+ showFilename=false,
crop,
cleanup,
force=false,
@@ -910,9 +928,9 @@ or \Lkeyval{b}.
%Now the same for side by side output.
-\subsubsection{the default -- side by side}
+%\textbf{the default -- side by side}
\begin{verbatim}
- align=\centering, mpwidth=0.5\linewidth,
+ align=\centering, mpwidth=0.5\linewidth, % default for side by side
\end{verbatim}
\begin{externalDocument}[
@@ -921,6 +939,7 @@ or \Lkeyval{b}.
BGbody=blue!8, BObody=blue,
code,
crop,
+ showFilename=false,
cleanup,
force=false,
mpwidth=0.5\linewidth,
@@ -932,7 +951,7 @@ or \Lkeyval{b}.
\end{document}
\end{externalDocument}
-\subsubsection{Left aligned -- side by side}
+%\textbf{Left aligned -- side by side}
\begin{verbatim}
align=\raggedright, mpwidth=0.5\linewidth,
@@ -944,6 +963,7 @@ or \Lkeyval{b}.
BGpreamble=red!10, BOpreamble=red,
BGbody=blue!8, BObody=blue,
code,
+ showFilename=false,
crop,
cleanup,
force=false,
@@ -956,7 +976,7 @@ or \Lkeyval{b}.
\end{document}
\end{externalDocument}
-\subsubsection{Right aligned -- side by side}
+%\textbf{Right aligned -- side by side}
\begin{verbatim}
align=\raggedleft, mpwidth=0.5\linewidth,
@@ -969,6 +989,7 @@ or \Lkeyval{b}.
BGpreamble=red!10, BOpreamble=red,
BGbody=blue!8, BObody=blue,
code,
+ showFilename=false,
crop,
cleanup,
force=false,
@@ -981,20 +1002,27 @@ or \Lkeyval{b}.
\end{document}
\end{externalDocument}
+
+
+
\subsection{Inline images}
By default code and image are own paragraphs. With the optional argument \Lkeyword{inline} the created
image can be part of the \Index{current line}. This may make sense, if you need characters which are
not part of your current font.
\begin{verbatim}
-\define@boolkey{hv}[hv@extern@]{inline}[true]{\hv@extern@codefalse}
+\define@boolkey{hv}[hv@extern@]{inline}[true]{%
+ \hv@extern@codefalse
+ \hv@extern@showFilenamefalse}
\end{verbatim}
-With the setting \LKeyset{inline=true} the optional keyword \Lkeyword{code} is automatically set to false. The
+With the setting \LKeyset{inline=true} the optional keyword \Lkeyword{code}
+is automatically set to false. The
next Chinese characters
\begin{externalDocument}[
compiler=xelatex, inline, runs=2, grfOptions={height=8pt},
- crop, cropmargin=0, cleanup, force=false, docType=latex]{voss}%
+ crop, cropmargin=0,
+ cleanup, force=false, docType=latex]{voss}%
\documentclass{ctexart}
\pagestyle{empty}
\begin{document}
@@ -1006,8 +1034,8 @@ are inserted as \Index{inline image} without showing the code. The complete code
\begin{Verbatim}
-With \Lkeyset{inline} the optional argument \Lkeyword{code} is automatically set to false. The
-next Chinese characters
+With \Lkeyset{inline} the optional argument \Lkeyword{code} is
+automatically set to false. The next Chinese characters
\begin{externalDocument}[
compiler=xelatex, inline, runs=2, grfOptions={height=8pt},
crop, cropmargin=0, cleanup, force=false, docType=latex]{voss}
@@ -1017,7 +1045,8 @@ next Chinese characters
美好的一天
\end{document}
\end{externalDocument}
-are inserted as inline image without showing the code. The complete code looks like:
+are inserted as inline image without showing the code. The complete
+code looks like:
\end{Verbatim}
@@ -1049,7 +1078,7 @@ sorted digits of the number $A$: $495=954-459$.
\begin{externalDocument}[
compiler=perl, force=false, docType=pl, ext=pl, includegraphic=false,
- code, mpwidth=0.6\linewidth]{voss}
+ code, mpwidth=0.6\linewidth, showFilename=false]{voss}
#!/usr/bin/perl
#
# Herbert Voss 2005-05-31
@@ -1103,7 +1132,8 @@ outFile = io.open(shortFN..".txt","w+") -- open external file
\begin{externalDocument}[
- compiler=lua, force=false, docType=lua, ext=lua, includegraphic=false, code, usefancyvrb=false]{voss}
+ compiler=lua, force=false, docType=lua, ext=lua, includegraphic=false,
+ code, usefancyvrb=false,textOptions={basicstyle=\ttfamily\footnotesize}]{voss}
#!/usr/bin/env lua
local filename = arg[0]
local shortFN = filename:match("(.+)%..+")
@@ -1181,6 +1211,7 @@ The following examples uses
xindexOptions={-l DE --config AU},
mpwidth=0.6\linewidth,
usefancyvrb=false,
+ showFilename=false,
docType=latex]{voss}
\documentclass[paper=a6,DIV=18,parskip=half-]{screxa}
\pagestyle{empty}
@@ -1228,6 +1259,7 @@ runsequence={lualatex,biber,{xindex -l de -c AU},lualatex,lualatex}
\begin{externalDocument}[
grfOptions={width=0.30\linewidth},
pages={1,3,5},
+ pagesep=2pt,
frame,
runsequence={lualatex,biber,xindex -l de -c AU,lualatex,lualatex},
showFilename,
@@ -1382,6 +1414,26 @@ it makes no difference using the optional argument \Lkeyword{usefancyvrb} or not
\end{externalDocument}
+%\clearpage
+
+
+\subsection{Vertical space}
+
+\begin{verbatim}
+\define@key{hv}{aboveskip}[\medskipamount]{\setlength\hv@extern@aboveskip{#1}}
+\define@key{hv}{belowpreambleskip}[\smallskipamount]{\setlength\hv@extern@belowpreambleskip{#1}}
+\define@key{hv}{belowbodyskip}[\smallskipamount]{\setlength\hv@extern@belowbodyskip{#1}}
+\define@key{hv}{belowskip}[\medskipamount]{\setlength\hv@extern@belowskip{#1}}
+\end{verbatim}
+
+\begin{description}
+\item[\Lkeyword{aboveskip}] Vertical space \emph{before} the environment \Lenv{externalDocument} or
+ the command \Lcs{runExtCmd} (default \Lcs{medskipamount})
+\item[\Lkeyword{belowpreambleskip}] Vertical space between preamble and body (default \Lcs{smallskipamount})
+\item[\Lkeyword{belowbodyskip}] Vertical space between body and output (default \Lcs{smallskipamount})
+\item[\Lkeyword{belowskip}] Vertical space \emph{after} the environment \Lenv{externalDocument} or
+ the command \Lcs{runExtCmd} (default \Lcs{medskipamount})
+\end{description}
\section{Supported engines}
\subsection{\MP\ example}
@@ -1525,6 +1577,7 @@ This is the start of the introduction.
\begin{externalDocument}[
grfOptions={width=0.3\linewidth},
pages={1,2,3},
+ pagesep=2pt,
frame,
verbose=false,
compiler=context,
@@ -1596,6 +1649,7 @@ already exists, there is no need to create it with the next run again and again.
\item[\Lkeyword{ExamplesDir}] move all examples into a directory
\item[\Lkeyset{tclbox=false}] Can be used if there are some negative interactions between package \Lpack{listings}
and package \Lpack{tcolorbox}.
+\item[\Lkeyword{framesep}] Value for \Lcs{fbox} if keyword \texttt{frame} is used.
\item[\Lkeyword{mpsep}] Distance between code and output (default 1\,em).
\item[\Lkeyword{pagesep}] Distance between pages for multipage output (default 1\,em).
\item[\Lkeyword{eps}] create an eps from the pdf (historical).
diff --git a/macros/latex/contrib/hvextern/latex/hvextern.sty b/macros/latex/contrib/hvextern/latex/hvextern.sty
index 2f7fb9d6ff..0b6eafa6c6 100644
--- a/macros/latex/contrib/hvextern/latex/hvextern.sty
+++ b/macros/latex/contrib/hvextern/latex/hvextern.sty
@@ -11,10 +11,11 @@
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
-\def\hvexternFileversion{0.24}
-\ProvidesFile{hvextern}[2022/05/11 v\hvexternFileversion: package for running external documents (HV)]
+\def\hvexternFileversion{0.25}
+\ProvidesFile{hvextern}[2022/05/19 v\hvexternFileversion: package for running external documents (HV)]
-\RequirePackage{shellesc,xkeyval,graphicx,marginnote,fancyvrb,tikz,listings,ifplatform}
+\RequirePackage{shellesc,xkeyval,graphicx}
+\RequirePackage{fancyvrb,tikz,listings,ifplatform}
\RequirePackage{tcolorbox,xparse}
\tcbuselibrary{skins,breakable}
@@ -30,8 +31,15 @@
\newcounter{@@@runs}
\newsavebox\hv@extern@box
\newlength\hv@LineWidth
+\newlength\hv@TextWidth
\newlength\hv@extern@pagesep
\newlength\hv@extern@mpsep
+\newlength\hv@extern@framesep
+\newlength\hv@extern@aboveskip
+\newlength\hv@extern@belowpreambleskip
+\newlength\hv@extern@belowbodyskip
+\newlength\hv@extern@belowskip
+
\AtBeginDocument{\setlength\hv@LineWidth{\dimexpr\linewidth-2\fboxsep-2\fboxrule}}
\newlength\hv@extern@mpwidth \setlength\hv@extern@mpwidth{\z@}
@@ -40,11 +48,18 @@
\define@key{hv}{runs}[1]{\setcounter{hv@extern@runs}{#1}}
\define@key{hv}{grfOptions}[]{\def\hv@extern@grfOptions{#1}}
\define@key{hv}{lstOptions}[]{\def\hv@extern@lstOptions{#1}}
+\define@key{hv}{textOptions}[]{\def\hv@extern@textOptions{#1}}
\define@key{hv}{BGpreamble}[black!12]{\def\hv@extern@BGpreamble{#1}}
\define@key{hv}{BGbody}[black!8]{\def\hv@extern@BGbody{#1}}
\define@key{hv}{BOpreamble}[black!12]{\def\hv@extern@BOpreamble{#1}}
\define@key{hv}{BObody}[black!8]{\def\hv@extern@BObody{#1}}
\define@key{hv}{docType}[latex]{\def\hv@extern@docType{#1}}
+%\define@choicekey*+{hv}{docType}[\val\nr]{latex,mp,tex,py,pl,lua,java,context,sh}[latex]{%
+% \hv@typeout{>>>> ´doc type \nr}%
+% \def\hv@extern@docType{\val}%
+%}{\PackageWarning{hvextern}{erroneous input (#1) for docType ignored. Using latex.}%
+% \def\hv@extern@docType{latex}%
+% }
\define@key{hv}{caption}[]{\def\hv@extern@caption{#1}}
\define@key{hv}{label}[]{\def\hv@extern@label{#1}}
\define@key{hv}{pages}[1]{\def\hv@extern@pages{#1}}
@@ -65,10 +80,11 @@
\define@boolkey{hv}[hv@extern@]{xindex}[true]{}
\define@key{hv}{xindexOptions}[]{\def\hv@extern@xindexOptions{#1}}
\define@boolkey{hv}[hv@extern@]{includegraphic}[true]{}
-\define@boolkey{hv}[hv@extern@]{inline}[true]{\hv@extern@codefalse}
+\define@boolkey{hv}[hv@extern@]{inline}[true]{\hv@extern@codefalse\hv@extern@showFilenamefalse}
\define@boolkey{hv}[hv@extern@]{frame}[true]{}
+\define@key{hv}{framesep}[\the\fboxsep]{\setlength\hv@extern@framesep{#1}}
\define@boolkey{hv}[hv@extern@]{float}[true]{}
-%\define@boolkey{hv}[hv@extern@]{cleanup}[true]{}
+\define@key{hv}{floatsetting}[]{\def\hv@extern@floatsetting{#1}}
\define@key{hv}{cleanup}[{aux,log}]{\def\hv@extern@cleanup{#1}}%
\define@boolkey{hv}[hv@extern@]{moveToExampleDir}[true]{}
\define@key{hv}{align}[\centering]{\def\hv@extern@align{#1}}
@@ -82,7 +98,6 @@
\define@boolkey{hv}[hv@extern@]{eps}[true]{}
\define@boolkey{hv}[hv@extern@]{verbose}[true]{}
\def\hv@typeout#1{\ifhv@extern@verbose\typeout{#1}\fi}
-
%\define@key{hv}{compiler}[pdflatex]{\def\hv@extern@compiler{#1}}
\define@choicekey*+{hv}{compiler}[\val\nr]{mpost,tex,latex,luatex,python3,perl,lua,java,%
xetex,pdflatex,lualatex,xelatex,context,sh,texlua}[pdflatex]{%
@@ -93,6 +108,10 @@
\def\hv@extern@compiler{pdflatex}%
\def\hv@extern@compilerNo{9}%
}
+\define@key{hv}{aboveskip}[\medskipamount]{\setlength\hv@extern@aboveskip{#1}}
+\define@key{hv}{belowpreambleskip}[\smallskipamount]{\setlength\hv@extern@belowpreambleskip{#1}}
+\define@key{hv}{belowbodyskip}[\smallskipamount]{\setlength\hv@extern@belowbodyskip{#1}}
+\define@key{hv}{belowskip}[\medskipamount]{\setlength\hv@extern@belowskip{#1}}
\def\ResetKeys{%
\setkeys{hv}{%
@@ -105,6 +124,7 @@
tcbox=true,% use tcolorbox
grfOptions={},% Optionen der einzubindenden Grafik
lstOptions={},% Optionen für das Listing
+ textOptions={},% Options for text output
BGpreamble=black!12,% Backgroundcolor for preamble
BGbody=black!8,% Backgroundcolor for body
BOpreamble=black!12,% Bodercolor for preamble
@@ -118,7 +138,9 @@
xindexOptions={},% options for xindex
force=false,% Compiler, auch wenn PDF existiert?
frame=false,% keinen Rahmen um Abbildung
+ framesep=\the\fboxsep,%
float=false,% nicht als Gleitumgebung
+ floatsetting=!htb,% placement
caption=,% keine Caption
label=,% kein Label
pages=1,% welche Seiten auszugeben sind
@@ -129,11 +151,16 @@
ExampleDir=Examples,% Unterverzeichnis für Beispiele
align=\centering,% Ausgabe zentrieren
mpwidth=0pt,% no minipage
+ mpsep=1em,% sep between two minipages
mpvalign=t,% if side by side output the vertical alignment
usefancyvrb=false,% use VerbatimInput instead of listings
progpath={},
cropmargin=2,% 2pb margin
eps=false,% create an eps output?
+ aboveskip=\medskipamount,% space above everything
+ belowpreambleskip=\smallskipamount,% space below preamble
+ belowbodyskip=\smallskipamount,% space below body
+ belowskip=\medskipamount,% space below everything
}%
}
@@ -167,10 +194,14 @@
\lstset{belowskip=0pt,aboveskip=0pt}% global
\tcbset{breakable,left=2pt,right=2pt,top=2pt,bottom=2pt,boxsep=0pt}
+\def\hv@marginpar#1{%
+ \makebox[\dimexpr\hv@TextWidth+\marginparsep-1ex][r]{\makebox(0,0){\rotatebox[origin=lb]{90}{#1}}}%
+}
+
\newcommand\PreambleVerbatim[2][]{%
\hv@typeout{Running PreambleVerbatim with #1, #2}%
\ifhv@extern@tcbox
- \begin{tcolorbox}\VerbatimInput[#1]{#2}\end{tcolorbox}%
+ \begin{tcolorbox}[before skip=0pt,after skip=0pt]\VerbatimInput[#1]{#2}\end{tcolorbox}%
\else
\VerbatimInput[#1]{#2}
\fi}
@@ -178,7 +209,7 @@
\newcommand\BodyVerbatim[2][]{%
\hv@typeout{Running BodyVerbatim with #1, #2}%
\ifhv@extern@tcbox
- \begin{tcolorbox}\VerbatimInput[#1]{#2}\end{tcolorbox}%
+ \begin{tcolorbox}[before skip=0pt,after skip=0pt]\VerbatimInput[#1]{#2}\end{tcolorbox}%
\else
\VerbatimInput[#1]{#2}
\fi}
@@ -186,17 +217,19 @@
\newcommand\PreambleListing[2][]{%
\hv@typeout{Running PreambleListing with #1, #2}%
\ifhv@extern@tcbox
- \begin{tcolorbox}[top=-2pt]\expandafter\lstinputlisting\expandafter[#1]{#2}\end{tcolorbox}%
+ \begin{tcolorbox}[before skip=0pt,after skip=0pt%,top=-2pt
+ ]\expandafter\lstinputlisting\expandafter[#1,aboveskip=0pt,belowskip=0pt]{#2}\end{tcolorbox}%
\else
- \expandafter\lstinputlisting\expandafter[#1]{#2}%
+ \expandafter\lstinputlisting\expandafter[#1,aboveskip=0pt,belowskip=0pt]{#2}%
\fi}
\newcommand\BodyListing[2][]{%
\hv@typeout{Running BodyListing with #1, #2}%
\ifhv@extern@tcbox
- \begin{tcolorbox}[top=-2pt]\expandafter\lstinputlisting\expandafter[#1]{#2}\end{tcolorbox}%
+ \begin{tcolorbox}[before skip=0pt,after skip=0pt,%top=-2pt
+ ]\expandafter\lstinputlisting\expandafter[#1,aboveskip=0pt,belowskip=0pt]{#2}\end{tcolorbox}%
\else
- \expandafter\lstinputlisting\expandafter[#1]{#2}%
+ \expandafter\lstinputlisting\expandafter[#1,aboveskip=0pt,belowskip=0pt]{#2}%
\fi}
\newcounter{hv@example@counter}
@@ -382,20 +415,26 @@
\fi
\fi% end force
\ifhv@extern@code%-------------- Code Part
- \hv@typeout{>>>>Starting Code part ...}%
- \par\noindent
+ \hv@typeout{>>>>Starting Code part with preamble ...}%
\begingroup
- \ifdim\hv@extern@mpwidth>\z@ \minipage[\hv@extern@mpvalign]{\hv@extern@mpwidth}\vspace{0pt}\fi
- \ifhv@extern@usefancyvrb
+ \hv@TextWidth=\textwidth
+ \ifdim\hv@extern@mpwidth>\z@
+ \noindent
+ \minipage[\hv@extern@mpvalign]{\hv@extern@mpwidth}
+ \vspace{0pt}%
+ \else
+ \vspace{\hv@extern@aboveskip}\noindent
+ \fi
+ \ifhv@extern@usefancyvrb
\@nameuse{\hv@extern@docType @initPreambleFancy}%
\edef\@@@temp{\@nameuse{\hv@extern@docType @initPreamble}}%
% we need lstinputlisting, because \VerbatimInput doesn't work in a box
\savebox\hv@extern@box{\expandafter\lstinputlisting\expandafter[\@@@temp]{\hvExternDateiname\hv@extern@ext}}%
-% \savebox\hv@extern@box{\VerbatimInput{\hvExternDateiname\hv@extern@ext}}%
\ifdim\wd\hv@extern@box > \z@\relax
\expandafter\fvset\expandafter{\hv@extern@lstOptions}%
\tcbset{colback=\hv@extern@BGpreamble,colframe=\hv@extern@BOpreamble}%
\PreambleVerbatim{\hvExternDateiname\hv@extern@ext}%
+ \vspace{\hv@extern@belowpreambleskip}%
\fi
\else
\edef\@@@temp{\@nameuse{\hv@extern@docType @initPreamble}}%
@@ -404,30 +443,35 @@
\expandafter\lstset\expandafter{\hv@extern@lstOptions}%
\tcbset{colback=\hv@extern@BGpreamble,colframe=\hv@extern@BOpreamble}%
\PreambleListing[\@@@temp]{\hvExternDateiname\hv@extern@ext}%
+ \vspace{\hv@extern@belowpreambleskip}%
\fi
\fi
\ifhv@extern@showFilename
- \marginnote{\rotatebox{90}{\hvExternDateiname\hv@extern@ext}}%[-15mm]%
+ \hv@typeout{>>>> Set filename in the margin!}%
+ \noindent
+ \hv@marginpar{\hvExternDateiname\hv@extern@ext}%
\fi
%
+ \hv@typeout{>>>>Starting Code body ...}%}
\ifhv@extern@usefancyvrb
\@nameuse{\hv@extern@docType @initTextFancy}%
\expandafter\fvset\expandafter{\hv@extern@lstOptions}%
\tcbset{colback=\hv@extern@BGbody,colframe=\hv@extern@BObody}%
\expandafter\BodyVerbatim\expandafter[\hv@extern@lstOptions]{\hvExternDateiname\hv@extern@ext}%
- \else
+ \else
\expandafter\lstset\expandafter{\hv@extern@lstOptions}%
\edef\@@@temp{\@nameuse{\hv@extern@docType @initText}}%
\tcbset{colback=\hv@extern@BGbody,colframe=\hv@extern@BObody}%
\BodyListing[\@@@temp]{\hvExternDateiname\hv@extern@ext}%
- \fi
- \ifdim\hv@extern@mpwidth > \z@\relax \endminipage\fi
- \endgroup
+ \fi
+ \ifdim\hv@extern@mpwidth > \z@\relax \endminipage\fi
+ \endgroup
\fi % end code part
\ifhv@extern@code\else % only if no code
\ifhv@extern@showFilename
\hv@typeout{>>>> Set filename in the margin!}%
- \marginnote{\rotatebox{90}{\hvExternDateiname}}%
+ \noindent
+ \hv@marginpar{\hvExternDateiname\hv@extern@ext}%
\fi
\fi
\ifhv@extern@moveToExampleDir
@@ -442,31 +486,37 @@
\else
\ifhv@extern@float
\hv@typeout{>>>> Floating environment}%
- \begin{figure}[!htb]
+ \expandafter\figure\expandafter[\hv@extern@floatsetting]
\else
\hv@typeout{>>>> No floating environment}%
+ \vspace{\hv@extern@belowbodyskip}
\ifdim\hv@extern@mpwidth>\z@
\hfill\minipage[\hv@extern@mpvalign]{\dimexpr\linewidth-\hv@extern@mpwidth-1em\relax}\vspace{0pt}%
\else
- \par\noindent\begingroup
+ \vspace{\hv@extern@belowbodyskip}\noindent
+ \begingroup
\fi
\fi
\hv@extern@align
\hv@typeout{>>>> Input image \hv@extern@ExamplesDir\hvExternDateiname}%
\ifhv@extern@frame
+ \begingroup
+ \fboxsep=\hv@extern@framesep
\expandafter\@for\expandafter\next\expandafter:\expandafter=\hv@extern@pages\do{%
- \fbox{\expandafter\includegraphics\expandafter[\hv@extern@grfOptions,page=\next]{\hv@extern@ExamplesDir\hvExternDateiname}}%
- \hspace{\hv@extern@pagesep}}\hspace*{-\hv@extern@pagesep}%
+ \fbox{\expandafter\includegraphics\expandafter[\hv@extern@grfOptions,page=\next]%
+ {\hv@extern@ExamplesDir\hvExternDateiname}}\hspace{\hv@extern@pagesep}}%
+ \hspace*{-\hv@extern@pagesep}%
+ \endgroup
\else
\expandafter\@for\expandafter\next\expandafter:\expandafter=\hv@extern@pages\do{%
\expandafter\includegraphics\expandafter[\hv@extern@grfOptions,page=\next]%
- {\hv@extern@ExamplesDir\hvExternDateiname}%
- \hspace{\hv@extern@pagesep}}\hspace*{-\hv@extern@pagesep}%
+ {\hv@extern@ExamplesDir\hvExternDateiname}\hspace{\hv@extern@pagesep}}%
+ \hspace*{-\hv@extern@pagesep}%
\fi
\ifx\hv@extern@caption\@empty\else\caption{\hv@extern@caption}\fi
\ifx\hv@extern@label\@empty\else\label{\hv@extern@label}\fi
\ifhv@extern@float
- \end{figure}%
+ \endfigure
\else
\ifdim\hv@extern@mpwidth>\z@ \endminipage\else\par\endgroup\fi
\fi
@@ -474,28 +524,26 @@
\else% no graphic, only text
\ifdim\hv@extern@mpwidth>\z@
\hfill\minipage[t]{\dimexpr\linewidth-\hv@extern@mpwidth-\hv@extern@mpsep\relax}\vspace{0pt}
- \noindent
\ifhv@extern@usefancyvrb
- \expandafter\BodyVerbatim\expandafter[\hv@extern@lstOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt}%
+ \expandafter\VerbatimInput\expandafter[\hv@extern@textOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt}%
\else
- \expandafter\BodyListing\expandafter[\hv@extern@lstOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt}%
+ \expandafter\lstinputlisting\expandafter[\hv@extern@textOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt}%
\fi
\endminipage
\else
+ \vspace{\hv@extern@belowbodyskip}
\noindent
\ifhv@extern@usefancyvrb
- \expandafter\BodyVerbatim\expandafter[\hv@extern@lstOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt}%
+ \expandafter\VerbatimInput\expandafter[\hv@extern@textOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt}%
\else
- \expandafter\BodyListing\expandafter[\hv@extern@lstOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt}%
+ \expandafter\lstinputlisting\expandafter[\hv@extern@textOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt}%
\fi
\fi
\fi
\ifhv@extern@force\expandafter\run@hv@extern@cleanup\expandafter{\hv@extern@cleanup}\fi% cleanup
+ \vspace{\hv@extern@belowskip}%
}
-\stepcounter{hv@example@counter}%
-
-
\newcommand\runExtCmd[3][]{%
\begingroup
\setkeys{hv}{code=false,includegraphic=false,#1}%
@@ -514,7 +562,7 @@
\else
\ifhv@extern@float
\hv@typeout{>>>> Floating environment}%
- \begin{figure}[!htb]
+ \expandafter\figure\expandafter[\hv@extern@floatsetting]
\else
\hv@typeout{>>>> No floating environment}%
\par\noindent\begingroup
@@ -522,9 +570,12 @@
\hv@extern@align
\hv@typeout{>>>> Input image \hv@extern@ExamplesDir\hvExternDateiname}%
\ifhv@extern@frame
+ \begingroup
+ \fboxsep=\hv@extern@framesep
\expandafter\@for\expandafter\next\expandafter:\expandafter=\hv@extern@pages\do{%
\fbox{\expandafter\includegraphics\expandafter[\hv@extern@grfOptions,page=\next]{\hv@extern@ExamplesDir\hvExternDateiname}}%
\hspace{5pt}}\hspace*{-5pt}%
+ \endgroup
\else
\expandafter\@for\expandafter\next\expandafter:\expandafter=\hv@extern@pages\do{%
\expandafter\includegraphics\expandafter[\hv@extern@grfOptions,page=\next]%
@@ -534,7 +585,7 @@
\ifx\hv@extern@caption\@empty\else\caption{\hv@extern@caption}\fi
\ifx\hv@extern@label\@empty\else\label{\hv@extern@label}\fi
\ifhv@extern@float
- \end{figure}%
+ \endfigure
\else
\ifdim\hv@extern@mpwidth>\z@ \endminipage\else\par\endgroup\fi
\fi
@@ -542,7 +593,7 @@
\else% no graphic, only text
\ifhv@extern@float
\hv@typeout{>>>> Floating environment}%
- \begin{figure}[!htb]
+ \expandafter\figure\expandafter[!htb]
\ifhv@extern@usefancyvrb
\expandafter\BodyVerbatim\expandafter[\hv@extern@lstOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt}
\else
@@ -550,7 +601,7 @@
\fi
\ifx\hv@extern@caption\@empty\else\caption{\hv@extern@caption}\fi
\ifx\hv@extern@label\@empty\else\label{\hv@extern@label}\fi
- \end{figure}
+ \endfigure
\else
\noindent
\ifhv@extern@usefancyvrb
@@ -563,6 +614,9 @@
\ifhv@extern@force\expandafter\run@hv@extern@cleanup\expandafter{\hv@extern@cleanup}\fi% cleanup
\endgroup
}
+
+\stepcounter{hv@example@counter}%
+
%
%%
\endinput