diff options
author | Karl Berry <karl@freefriends.org> | 2022-05-11 19:51:39 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-05-11 19:51:39 +0000 |
commit | e61a87f98a798358891c94904b47cfef50386581 (patch) | |
tree | 91eae58153bd0aefd8dcc4708a0166d025278f3b /Master/texmf-dist/tex/latex/hvextern/hvextern.sty | |
parent | ba42eb36e2f9b61f1477e16c5794f24d1c7abc96 (diff) |
hvextern (11may22)
git-svn-id: svn://tug.org/texlive/trunk@63280 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/hvextern/hvextern.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/hvextern/hvextern.sty | 60 |
1 files changed, 44 insertions, 16 deletions
diff --git a/Master/texmf-dist/tex/latex/hvextern/hvextern.sty b/Master/texmf-dist/tex/latex/hvextern/hvextern.sty index 5179123aa2e..2f7fb9d6ff1 100644 --- a/Master/texmf-dist/tex/latex/hvextern/hvextern.sty +++ b/Master/texmf-dist/tex/latex/hvextern/hvextern.sty @@ -11,8 +11,8 @@ %% and version 1.3c or later is part of all distributions of LaTeX %% version 2005/12/01 or later. -\def\hvexternFileversion{0.23} -\ProvidesFile{hvextern}[2022/05/08 v\hvexternFileversion: package for running external documents (HV)] +\def\hvexternFileversion{0.24} +\ProvidesFile{hvextern}[2022/05/11 v\hvexternFileversion: package for running external documents (HV)] \RequirePackage{shellesc,xkeyval,graphicx,marginnote,fancyvrb,tikz,listings,ifplatform} \RequirePackage{tcolorbox,xparse} @@ -30,6 +30,8 @@ \newcounter{@@@runs} \newsavebox\hv@extern@box \newlength\hv@LineWidth +\newlength\hv@extern@pagesep +\newlength\hv@extern@mpsep \AtBeginDocument{\setlength\hv@LineWidth{\dimexpr\linewidth-2\fboxsep-2\fboxrule}} \newlength\hv@extern@mpwidth \setlength\hv@extern@mpwidth{\z@} @@ -46,8 +48,10 @@ \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}} +\define@key{hv}{pagesep}[1em]{\hv@extern@pagesep=#1} \define@key{hv}{cropmargin}[2]{\def\hv@extern@cropmargin{#1 }} \define@key{hv}{mpwidth}[0pt]{\setlength\hv@extern@mpwidth{#1}} +\define@key{hv}{mpsep}[1em]{\setlength\hv@extern@mpsep{#1}} \define@key{hv}{mpvalign}[t]{\def\hv@extern@mpvalign{#1}} \define@key{hv}{ext}[tex]{\def\hv@extern@ext{.#1}} \define@boolkey{hv}[hv@extern@]{redirect}[true]{} @@ -91,7 +95,7 @@ } \def\ResetKeys{% - \setkeys{hv}{ + \setkeys{hv}{% showFilename=false,% Dateinamen im Rand angeben ext=tex,% file extension code=false,% show Code @@ -118,6 +122,7 @@ caption=,% keine Caption label=,% kein Label pages=1,% welche Seiten auszugeben sind + pagesep=1em,% horizontal sep between pages docType=latex,% LaTeX example Code cleanup={},% Hilfsdateien nicht löschen moveToExampleDir=false,% Verschieben nach ExamplesDir @@ -147,7 +152,7 @@ { \clist_map_inline:nn {#1}{\ShellEscape{\hv@rm \hv@extern@ExamplesDir\hvExternDateiname.##1}} \ifnum\hv@extern@compilerNo=0\relax % we have metapost - \hv@rm epsf.* + \ShellEscape{\hv@rm\space epsf.*}% \fi } \NewDocumentCommand\run@hv@extern@sequenceList{ m } @@ -163,6 +168,7 @@ \tcbset{breakable,left=2pt,right=2pt,top=2pt,bottom=2pt,boxsep=0pt} \newcommand\PreambleVerbatim[2][]{% + \hv@typeout{Running PreambleVerbatim with #1, #2}% \ifhv@extern@tcbox \begin{tcolorbox}\VerbatimInput[#1]{#2}\end{tcolorbox}% \else @@ -170,6 +176,7 @@ \fi} \newcommand\BodyVerbatim[2][]{% + \hv@typeout{Running BodyVerbatim with #1, #2}% \ifhv@extern@tcbox \begin{tcolorbox}\VerbatimInput[#1]{#2}\end{tcolorbox}% \else @@ -177,13 +184,15 @@ \fi} \newcommand\PreambleListing[2][]{% + \hv@typeout{Running PreambleListing with #1, #2}% \ifhv@extern@tcbox \begin{tcolorbox}[top=-2pt]\expandafter\lstinputlisting\expandafter[#1]{#2}\end{tcolorbox}% - \else + \else \expandafter\lstinputlisting\expandafter[#1]{#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}% \else @@ -321,9 +330,9 @@ \global\hv@extern@forcetrue}}}% set force, if no pdf or png exists \begingroup \hv@typeout{>>> writing file \hvExternDateiname\hv@extern@ext ...}% - \filecontents[force,noheader]{\hvExternDateiname\hv@extern@ext} + \filecontents[force,noheader]{\hvExternDateiname\hv@extern@ext}% } - {\endfilecontents% \end + {\endfilecontents% \end% \hv@typeout{>>> ... done}% \global\stepcounter{hv@example@counter}% \endgroup @@ -383,7 +392,7 @@ % 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@ + \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}% @@ -391,7 +400,7 @@ \else \edef\@@@temp{\@nameuse{\hv@extern@docType @initPreamble}}% \savebox\hv@extern@box{\expandafter\lstinputlisting\expandafter[\@@@temp]{\hvExternDateiname\hv@extern@ext}}% - \ifdim\wd\hv@extern@box>\z@ + \ifdim\wd\hv@extern@box>\z@\relax \expandafter\lstset\expandafter{\hv@extern@lstOptions}% \tcbset{colback=\hv@extern@BGpreamble,colframe=\hv@extern@BOpreamble}% \PreambleListing[\@@@temp]{\hvExternDateiname\hv@extern@ext}% @@ -447,12 +456,12 @@ \ifhv@extern@frame \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}% + \hspace{\hv@extern@pagesep}}\hspace*{-\hv@extern@pagesep}% \else \expandafter\@for\expandafter\next\expandafter:\expandafter=\hv@extern@pages\do{% \expandafter\includegraphics\expandafter[\hv@extern@grfOptions,page=\next]% {\hv@extern@ExamplesDir\hvExternDateiname}% - \hspace{5pt}}\hspace*{-5pt}% + \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 @@ -464,11 +473,21 @@ \fi \else% no graphic, only text \ifdim\hv@extern@mpwidth>\z@ - \hfill\minipage[t]{\dimexpr\linewidth-\hv@extern@mpwidth-1em\relax}\vspace{0pt} - \noindent\BodyListing{\hv@extern@ExamplesDir\hvExternDateiname.txt} + \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}% + \else + \expandafter\BodyListing\expandafter[\hv@extern@lstOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt}% + \fi \endminipage \else - \noindent\BodyListing{\hv@extern@ExamplesDir\hvExternDateiname.txt} + \noindent + \ifhv@extern@usefancyvrb + \expandafter\BodyVerbatim\expandafter[\hv@extern@lstOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt}% + \else + \expandafter\BodyListing\expandafter[\hv@extern@lstOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt}% + \fi \fi \fi \ifhv@extern@force\expandafter\run@hv@extern@cleanup\expandafter{\hv@extern@cleanup}\fi% cleanup @@ -524,12 +543,21 @@ \ifhv@extern@float \hv@typeout{>>>> Floating environment}% \begin{figure}[!htb] - \noindent\BodyListing{\hv@extern@ExamplesDir\hvExternDateiname.txt} + \ifhv@extern@usefancyvrb + \expandafter\BodyVerbatim\expandafter[\hv@extern@lstOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt} + \else + \expandafter\BodyListing\expandafter[\hv@extern@lstOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt} + \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} \else - \noindent\BodyListing{\hv@extern@ExamplesDir\hvExternDateiname.txt} + \noindent + \ifhv@extern@usefancyvrb + \expandafter\BodyVerbatim\expandafter[\hv@extern@lstOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt} + \else + \expandafter\BodyListing\expandafter[\hv@extern@lstOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt} + \fi \fi \fi \ifhv@extern@force\expandafter\run@hv@extern@cleanup\expandafter{\hv@extern@cleanup}\fi% cleanup |