From 493ae31d5a338e09792bebe93150467f76b80109 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 23 May 2022 19:56:28 +0000 Subject: hvextern (23may22) git-svn-id: svn://tug.org/texlive/trunk@63380 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/hvextern/Changes | 2 + Master/texmf-dist/doc/latex/hvextern/hvextern.pdf | Bin 1203306 -> 1204768 bytes Master/texmf-dist/doc/latex/hvextern/hvextern.tex | 37 +++++--- Master/texmf-dist/tex/latex/hvextern/hvextern.sty | 101 +++++++++++++++++----- 4 files changed, 104 insertions(+), 36 deletions(-) diff --git a/Master/texmf-dist/doc/latex/hvextern/Changes b/Master/texmf-dist/doc/latex/hvextern/Changes index c83eea6c1fe..b3003961062 100644 --- a/Master/texmf-dist/doc/latex/hvextern/Changes +++ b/Master/texmf-dist/doc/latex/hvextern/Changes @@ -1,5 +1,7 @@ hvextern.sty ---------------- +v 0.26 2022-05-23 - set filenames for twocolumn mode outer/inner + - added keywords outerFN and shiftFN v 0.25 2022-05-19 - added framesep keyword - added keywords for vertical space - added keyword textOptions for reading text output diff --git a/Master/texmf-dist/doc/latex/hvextern/hvextern.pdf b/Master/texmf-dist/doc/latex/hvextern/hvextern.pdf index b472862835d..473cd8972b3 100644 Binary files a/Master/texmf-dist/doc/latex/hvextern/hvextern.pdf and b/Master/texmf-dist/doc/latex/hvextern/hvextern.pdf differ diff --git a/Master/texmf-dist/doc/latex/hvextern/hvextern.tex b/Master/texmf-dist/doc/latex/hvextern/hvextern.tex index a170457a7d6..d691aa3bed0 100644 --- a/Master/texmf-dist/doc/latex/hvextern/hvextern.tex +++ b/Master/texmf-dist/doc/latex/hvextern/hvextern.tex @@ -30,7 +30,7 @@ from within a main\newline \LaTeX\ document~--v. \hvexternFileversion} %\newpage -\setkeys{hv}{moveToExampleDir,ExampleDir=Examples,showFilename,verbose} +\setkeys{hv}{moveToExampleDir,ExampleDir=Exa,showFilename,verbose} \section{Syntax} \begin{verbatim} @@ -268,6 +268,18 @@ image.save(imageName+".png", "PNG") \end{externalDocument} +The external filename, extended by a consequtive number, kan be printed in the +margin by setting the keyword \Lkeyword{showFilename}. In general it is printed +in the outer margin or in twocolumn mode in the outer column. If the example is +set in twocolumn mode but inside a starred floating environment over both +column, then use the keyword \Lkeyword{outerFN}. Then \Lpack{hvextern} doesn't +test for twocolumn mode. + +A vertical shift of the filename is possible by setting a length to the keyword \Lkeyword{shiftFN}, +e.g. \texttt{shiftFN=5ex}. + + +\clearpage%%%%%%%%%%%% \begin{externalDocument}[grfOptions={width=0.95\linewidth}, compiler=xelatex,code,mpwidth=0.6\linewidth, @@ -412,9 +424,6 @@ 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: @@ -681,6 +690,7 @@ The following example uses: \begin{externalDocument}[ pages={1,2,3}, pagesep=2pt, + shiftFN=5ex, grfOptions={width=0.3\linewidth}, % lstOptions={fontsize=\small,fontfamily=tt}, compiler=lualatex, runs=2, @@ -690,7 +700,7 @@ The following example uses: % mpwidth=0.6\linewidth, % crop, cleanup, - force=true, + force=false, frame, % usefancyvrb, % float, @@ -743,7 +753,7 @@ which is the default. Using a caption and a label are optional. % mpwidth=0.6\linewidth, crop, cleanup, - force=true, + force=false, usefancyvrb, float, floatsetting=!ht, @@ -1016,7 +1026,7 @@ not part of your current font. \hv@extern@showFilenamefalse} \end{verbatim} -With the setting \LKeyset{inline=true} the optional keyword \Lkeyword{code} +With the setting \LKeyset{inline=true} the optional keyword \Lkeyword{code} and \Lkeyword{showFilename} is automatically set to false. The next Chinese characters \begin{externalDocument}[ @@ -1078,7 +1088,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, showFilename=false]{voss} + code, mpwidth=0.6\linewidth]{voss} #!/usr/bin/perl # # Herbert Voss 2005-05-31 @@ -1133,7 +1143,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,textOptions={basicstyle=\ttfamily\footnotesize}]{voss} + code, usefancyvrb=false,textOptions={basicstyle=\ttfamily\footnotesize}, + shiftFN=6ex]{voss} #!/usr/bin/env lua local filename = arg[0] local shortFN = filename:match("(.+)%..+") @@ -1211,7 +1222,6 @@ 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} @@ -1262,7 +1272,6 @@ runsequence={lualatex,biber,{xindex -l de -c AU},lualatex,lualatex} pagesep=2pt, frame, runsequence={lualatex,biber,xindex -l de -c AU,lualatex,lualatex}, - showFilename, verbose, force=false, cleanup={log,aux,toc,bbl,blg}, @@ -1304,7 +1313,6 @@ The default is using \Lcs{lstinputlisting} for the printed code sequences. grfOptions={width=0.45\linewidth}, pages={1,3}, frame,compiler=pdflatex, - showFilename, % crop, force=false,runs=2,code,docType=latex, frame, @@ -1641,6 +1649,11 @@ to get the directory listed: \section{Other options} \begin{description} +%\item[\Lkeyword{showFilename}] Prints the filename in the outer margin (right for oneside) or in twocolumn mode for +% the first column in the left and the second column in the right margin. +%\item[\Lkeyword{outerFN}] Only valid for the twocolumn mode with onecolumn floats (environment \texttt{figure*}), +% to get the filename on the right or left of the whole page. +%\item[\Lkeyword{shiftFN}] A length to move the printed filename up or down. \item[\Lkeyset{force=false}] can speed up the comiling time for the document. If a created image/output already exists, there is no need to create it with the next run again and again. \item[\Lkeyword{cleanup}] the auxiliary files of a \LaTeX-run are deleted, preset to \texttt{aux}, \texttt{log}. diff --git a/Master/texmf-dist/tex/latex/hvextern/hvextern.sty b/Master/texmf-dist/tex/latex/hvextern/hvextern.sty index 0b6eafa6c6d..8b0fa75f1f4 100644 --- a/Master/texmf-dist/tex/latex/hvextern/hvextern.sty +++ b/Master/texmf-dist/tex/latex/hvextern/hvextern.sty @@ -11,11 +11,12 @@ %% and version 1.3c or later is part of all distributions of LaTeX %% version 2005/12/01 or later. -\def\hvexternFileversion{0.25} -\ProvidesFile{hvextern}[2022/05/19 v\hvexternFileversion: package for running external documents (HV)] +\def\hvexternFileversion{0.26} +\ProvidesFile{hvextern}[2022/05/23 v\hvexternFileversion: package for running external documents (HV)] \RequirePackage{shellesc,xkeyval,graphicx} \RequirePackage{fancyvrb,tikz,listings,ifplatform} +\RequirePackage{ifoddpage} \RequirePackage{tcolorbox,xparse} \tcbuselibrary{skins,breakable} @@ -39,6 +40,7 @@ \newlength\hv@extern@belowpreambleskip \newlength\hv@extern@belowbodyskip \newlength\hv@extern@belowskip +\newlength\hv@extern@shiftFN \AtBeginDocument{\setlength\hv@LineWidth{\dimexpr\linewidth-2\fboxsep-2\fboxrule}} \newlength\hv@extern@mpwidth \setlength\hv@extern@mpwidth{\z@} @@ -72,6 +74,8 @@ \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@]{outerFN}[true]{} +\define@key{hv}{shiftFN}[0pt]{\setlength\hv@extern@shiftFN{#1}} \define@boolkey{hv}[hv@extern@]{code}[true]{} \define@boolkey{hv}[hv@extern@]{force}[true]{} \define@boolkey{hv}[hv@extern@]{crop}[true]{} @@ -98,7 +102,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]{% \hv@typeout{>>>> Compiler type \nr}% @@ -113,9 +116,13 @@ \define@key{hv}{belowbodyskip}[\smallskipamount]{\setlength\hv@extern@belowbodyskip{#1}} \define@key{hv}{belowskip}[\medskipamount]{\setlength\hv@extern@belowskip{#1}} +\def\hvExternSetKeys#1{\setkeys{hv}{#1}} + \def\ResetKeys{% \setkeys{hv}{% showFilename=false,% Dateinamen im Rand angeben + outerFN=false,% use fullwidth in twocolumn mode (starred floats) + shiftFN=\z@,% raise printed filename ext=tex,% file extension code=false,% show Code crop=false,% erzeugte PDF "croppen" @@ -164,6 +171,7 @@ }% } + \ResetKeys {\catcode`\%=12 @@ -195,7 +203,39 @@ \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}}}% + \leavevmode\checkoddpage + \sbox\hv@extern@box{\rotatebox[origin=C]{90}{\rule{2\hv@extern@shiftFN}{0pt}#1}}% + \ht\hv@extern@box=\z@ \wd\hv@extern@box=\z@ \dp\hv@extern@box=\z@ + \noindent + \ifoddpage% we have a right page + \if@twocolumn + \ifhv@extern@outerFN + \makebox[\dimexpr\hv@TextWidth+\marginparsep-1.5ex][r]{\usebox\hv@extern@box}% + \else + \if@firstcolumn + \llap{\usebox\hv@extern@box\rule{2.5ex}{0pt}}% + \else + \makebox[\dimexpr\hv@TextWidth+\marginparsep-1.5ex][r]{\usebox\hv@extern@box}% + \fi + \fi + \else + \makebox[\dimexpr\hv@TextWidth+\marginparsep-1.5ex][r]{\usebox\hv@extern@box}% + \fi + \else% we have an even page (left page) + \if@twocolumn + \ifhv@extern@outerFN + \llap{\usebox\hv@extern@box\rule{2.5ex}{0pt}}% left page left side + \else + \if@firstcolumn + \llap{\usebox\hv@extern@box\rule{2.5ex}{0pt}}% left page left side + \else + \makebox[\dimexpr\hv@TextWidth+\marginparsep-1.5ex][r]{\usebox\hv@extern@box}% left page right side + \fi + \fi + \else + \llap{\usebox\hv@extern@box\rule{2.5ex}{0pt}}% onecolumn left page left side + \fi + \fi } \newcommand\PreambleVerbatim[2][]{% @@ -353,8 +393,10 @@ %% %% [#1]: Optionen #2: Dateiname %% -\newenvironment{externalDocument}[2][]{% +\newenvironment{externalDocument}[2][] + {% \xdef\hvExternDateiname{#2-\arabic{hv@example@counter}}% + \gdef\hv@extern@savePara{#1}% \setkeys{hv}{#1}% \begin \hv@typeout{External filename: \hvExternDateiname}% \expandafter\IfFileExists\expandafter{\hv@extern@ExamplesDir\hvExternDateiname.pdf}{}{% @@ -369,6 +411,8 @@ \hv@typeout{>>> ... done}% \global\stepcounter{hv@example@counter}% \endgroup + \expandafter\hvExternSetKeys\expandafter{\hv@extern@savePara}% + \xdef\hv@extern@fullPath{\hv@extern@ExamplesDir\hvExternDateiname}% \ifhv@extern@force \ifx\hv@extern@runsequence\@empty \hv@typeout{>>>> force=true: running \hv@extern@progpath\hv@extern@compiler~ \hvExternDateiname\hv@extern@ext ...}% @@ -417,7 +461,15 @@ \ifhv@extern@code%-------------- Code Part \hv@typeout{>>>>Starting Code part with preamble ...}% \begingroup - \hv@TextWidth=\textwidth + \if@twocolumn + \ifhv@extern@outerFN + \hv@TextWidth=\textwidth + \else + \hv@TextWidth=\columnwidth + \fi + \else + \hv@TextWidth=\textwidth + \fi \ifdim\hv@extern@mpwidth>\z@ \noindent \minipage[\hv@extern@mpvalign]{\hv@extern@mpwidth} @@ -477,12 +529,12 @@ \ifhv@extern@moveToExampleDir % \ShellEscape{mkdir\space\hv@extern@ExamplesDir/}% \hv@typeout{>>>> Move file into example dir}% - \hv@typeout{>>>>>>\hvExternDateiname ---- \hv@extern@ExamplesDir}% + \hv@typeout{>>>>>>\hvExternDateiname ----> \hv@extern@ExamplesDir}% \ShellEscape{\hv@move \hvExternDateiname.*\space \hv@extern@ExamplesDir}% \fi \ifhv@extern@includegraphic \ifhv@extern@inline - \expandafter\includegraphics\expandafter[\hv@extern@grfOptions]{\hv@extern@ExamplesDir\hvExternDateiname}% + \expandafter\includegraphics\expandafter[\hv@extern@grfOptions]{\hv@extern@fullPath}% \else \ifhv@extern@float \hv@typeout{>>>> Floating environment}% @@ -498,19 +550,21 @@ \fi \fi \hv@extern@align - \hv@typeout{>>>> Input image \hv@extern@ExamplesDir\hvExternDateiname}% + \hv@typeout{>>>> Input image \hv@extern@fullPath}% \ifhv@extern@frame \begingroup \fboxsep=\hv@extern@framesep \expandafter\@for\expandafter\next\expandafter:\expandafter=\hv@extern@pages\do{% + \hv@typeout{>>>> Image loop: next=\next\space \hv@extern@fullPath}% \fbox{\expandafter\includegraphics\expandafter[\hv@extern@grfOptions,page=\next]% - {\hv@extern@ExamplesDir\hvExternDateiname}}\hspace{\hv@extern@pagesep}}% + {\hv@extern@fullPath}}\hspace{\hv@extern@pagesep}}% \hspace*{-\hv@extern@pagesep}% \endgroup \else \expandafter\@for\expandafter\next\expandafter:\expandafter=\hv@extern@pages\do{% + \hv@typeout{>>>> Image loop: next=\next\space \hv@extern@fullPath}% \expandafter\includegraphics\expandafter[\hv@extern@grfOptions,page=\next]% - {\hv@extern@ExamplesDir\hvExternDateiname}\hspace{\hv@extern@pagesep}}% + {\hv@extern@fullPath}\hspace{\hv@extern@pagesep}}% \hspace*{-\hv@extern@pagesep}% \fi \ifx\hv@extern@caption\@empty\else\caption{\hv@extern@caption}\fi @@ -518,25 +572,25 @@ \ifhv@extern@float \endfigure \else - \ifdim\hv@extern@mpwidth>\z@ \endminipage\else\par\endgroup\fi + \ifdim\hv@extern@mpwidth>\z@ \endminipage\else\unskip\strut\par\endgroup\fi \fi \fi \else% no graphic, only text \ifdim\hv@extern@mpwidth>\z@ \hfill\minipage[t]{\dimexpr\linewidth-\hv@extern@mpwidth-\hv@extern@mpsep\relax}\vspace{0pt} \ifhv@extern@usefancyvrb - \expandafter\VerbatimInput\expandafter[\hv@extern@textOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt}% + \expandafter\VerbatimInput\expandafter[\hv@extern@textOptions]{\hv@extern@fullPath.txt}% \else - \expandafter\lstinputlisting\expandafter[\hv@extern@textOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt}% + \expandafter\lstinputlisting\expandafter[\hv@extern@textOptions]{\hv@extern@fullPath.txt}% \fi \endminipage \else \vspace{\hv@extern@belowbodyskip} \noindent \ifhv@extern@usefancyvrb - \expandafter\VerbatimInput\expandafter[\hv@extern@textOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt}% + \expandafter\VerbatimInput\expandafter[\hv@extern@textOptions]{\hv@extern@fullPath.txt}% \else - \expandafter\lstinputlisting\expandafter[\hv@extern@textOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt}% + \expandafter\lstinputlisting\expandafter[\hv@extern@textOptions]{\hv@extern@fullPath.txt}% \fi \fi \fi @@ -548,6 +602,7 @@ \begingroup \setkeys{hv}{code=false,includegraphic=false,#1}% \xdef\hvExternDateiname{#3-\arabic{hv@example@counter}}% + \xdef\hv@extern@fullPath{\hv@extern@ExamplesDir\hvExternDateiname}% \hv@typeout{>>>> running #2}% \ifhv@extern@redirect \ShellEscape{\hv@extern@progpath#2 > \hv@extern@ExamplesDir\hvExternDateiname.txt}% @@ -573,13 +628,12 @@ \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}}% + \fbox{\expandafter\includegraphics\expandafter[\hv@extern@grfOptions,page=\next]{\hv@extern@fullPath}}% \hspace{5pt}}\hspace*{-5pt}% \endgroup \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@fullPath}% \hspace{5pt}}\hspace*{-5pt}% \fi \ifx\hv@extern@caption\@empty\else\caption{\hv@extern@caption}\fi @@ -595,9 +649,9 @@ \hv@typeout{>>>> Floating environment}% \expandafter\figure\expandafter[!htb] \ifhv@extern@usefancyvrb - \expandafter\BodyVerbatim\expandafter[\hv@extern@lstOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt} + \expandafter\BodyVerbatim\expandafter[\hv@extern@lstOptions]{\hv@extern@fullPath.txt} \else - \expandafter\BodyListing\expandafter[\hv@extern@lstOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt} + \expandafter\BodyListing\expandafter[\hv@extern@lstOptions]{\hv@extern@fullPath.txt} \fi \ifx\hv@extern@caption\@empty\else\caption{\hv@extern@caption}\fi \ifx\hv@extern@label\@empty\else\label{\hv@extern@label}\fi @@ -605,9 +659,9 @@ \else \noindent \ifhv@extern@usefancyvrb - \expandafter\BodyVerbatim\expandafter[\hv@extern@lstOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt} + \expandafter\BodyVerbatim\expandafter[\hv@extern@lstOptions]{\hv@extern@fullPath.txt} \else - \expandafter\BodyListing\expandafter[\hv@extern@lstOptions]{\hv@extern@ExamplesDir\hvExternDateiname.txt} + \expandafter\BodyListing\expandafter[\hv@extern@lstOptions]{\hv@extern@fullPath.txt} \fi \fi \fi @@ -616,7 +670,6 @@ } \stepcounter{hv@example@counter}% - % %% \endinput -- cgit v1.2.3