diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/docshots/docshots.sty | 99 |
1 files changed, 74 insertions, 25 deletions
diff --git a/Master/texmf-dist/tex/latex/docshots/docshots.sty b/Master/texmf-dist/tex/latex/docshots/docshots.sty index 44abfe234f9..4725e69c2db 100644 --- a/Master/texmf-dist/tex/latex/docshots/docshots.sty +++ b/Master/texmf-dist/tex/latex/docshots/docshots.sty @@ -31,7 +31,14 @@ \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{docshots} -[2022-10-16 0.0.2 TeX Samples Next to Their PDF Snapshots in DTX] +[2022-10-17 0.0.3 TeX Samples Next to Their PDF Snapshots in DTX] + + + + + + + @@ -60,6 +67,12 @@ \pgfkeys{ /docshots/.cd, dtx/.store in=\docshots@dtx, + tmpdir/.store in=\docshots@tmpdir, + tmpdir/.default=_docshots, + small/.store in=\docshots@small, + tiny/.store in=\docshots@tiny, + runs/.store in=\docshots@runs, + runs/.default=1, pdflatex/.store in=\docshots@pdflatex, pdflatex/.default=pdflatex, gs/.store in=\docshots@gs, @@ -69,12 +82,12 @@ margin/.store in=\docshots@margin, margin/.default=5, hspace/.store in=\docshots@hspace, - hspace/.default=1.8em, + hspace/.default=.05\linewidth, left/.store in=\docshots@left, left/.default=.3\linewidth, right/.store in=\docshots@right, - right/.default=.65\linewidth, - pdflatex,gs,pdfcrop,margin,hspace,left,right + right/.default=.55\linewidth, + tmpdir,pdflatex,gs,pdfcrop,margin,hspace,left,right,runs } \ProcessPgfOptions{/docshots} @@ -84,44 +97,80 @@ \iexec[log,quiet]{\docshots@gs\space --version}% -\iexec[null]{mkdir -p _docshots/\jobname}% +\iexec[null]{mkdir -p \docshots@tmpdir/\jobname}% \newenvironment{docshot} {\VerbatimEnvironment\begin{VerbatimOut} - {_docshots/\jobname/verbatim.tex}} + {\docshots@tmpdir/\jobname/verbatim.tex}} {\end{VerbatimOut}% \ifdefined\docshots@dtx% \iexec[null]{perl -i -0777pe "s/(\\n|^)\\x{25} /\\1/g" - _docshots/\jobname/verbatim.tex}% + \docshots@tmpdir/\jobname/verbatim.tex}% \fi% - \def\hash{\pdfmdfivesum file {_docshots/\jobname/verbatim.tex}}% - \IfFileExists{_docshots/\jobname/\hash.pdf} - {\message{won't render, the PDF already exists: _docshots/\jobname/\hash.pdf^^J}} - {\iexec[log,quiet]{cp _docshots/\jobname/verbatim.tex - _docshots/\jobname/\hash.tex}% - \iexec[log,quiet]{cd _docshots/\jobname; - \docshots@pdflatex\space -interaction=batchmode - -shell-escape \hash.tex}}% - \IfFileExists{_docshots/\jobname/\hash.crop.pdf} - {\message{won't pdfcrop, the PDF already exists: _docshots/\jobname/\hash.crop.pdf^^J}} + \def\hash{\pdfmdfivesum file {\docshots@tmpdir/\jobname/verbatim.tex}}% + \IfFileExists{\docshots@tmpdir/\jobname/\hash.pdf} + {\message{docshots: won't render, the PDF already exists + (\docshots@tmpdir/\jobname/\hash.pdf)^^J}} + {\iexec[log,quiet]{cp \docshots@tmpdir/\jobname/verbatim.tex + \docshots@tmpdir/\jobname/\hash.tex}% + \foreach \n in {1,...,\docshots@runs}{ + \iexec[log,quiet]{cd \docshots@tmpdir/\jobname; + \docshots@pdflatex\space + -interaction=errorstopmode + -halt-on-error + -shell-escape + \hash.tex} + \message{docshots: pdflatex run no.\n^^J} + \IfFileExists{\docshots@tmpdir/\jobname/after.sh} + {\iexec[log,quiet]{chmod a+x + \docshots@tmpdir/\jobname/after.sh} + \iexec[log,quiet]{cd \docshots@tmpdir/\jobname; + ./after.sh \n\space \hash\space \hash.tex}} + {}}}% + \iexec[log,quiet]{rm -f \docshots@tmpdir/\jobname/after.sh} + \IfFileExists{\docshots@tmpdir/\jobname/\hash.crop.pdf} + {\message{docshots: on't pdfcrop, the PDF already exists + (\docshots@tmpdir/\jobname/\hash.crop.pdf)^^J}} {\iexec[log,quiet]{\docshots@pdfcrop\space --margins \docshots@margin\space - _docshots/\jobname/\hash.pdf - _docshots/\jobname/\hash.crop.pdf}}% - \fvset{frame=leftline,numbers=left,numbersep=3pt, - framerule=.4pt,rulecolor=\color{gray}, - samepage=true}% + \docshots@tmpdir/\jobname/\hash.pdf + \docshots@tmpdir/\jobname/\hash.crop.pdf}}% + \fvset{numbers=left,numbersep=3pt}% + \fvset{frame=leftline,framerule=.4pt,rulecolor=\color{gray}}% + \fvset{samepage=true,baselinestretch=1}% + \fvset{baselinestretch=1}% + \ifdefined\docshots@small% + \fvset{fontsize=\small}% + \fi% + \ifdefined\docshots@tiny% + \fvset{fontsize=\scriptsize}% + \fi% + \begingroup% \par% - \tikz[baseline=(a.north)] \node[draw=gray] (a) + \tikz[baseline=(a.north)] + \node (a) [draw=gray] {\includegraphics[width=\docshots@left] - {_docshots/\jobname/\hash.crop.pdf}};% + {\docshots@tmpdir/\jobname/\hash.crop.pdf}};% \hspace{\docshots@hspace}% \begin{minipage}[t]{\docshots@right}% \vspace{0pt}% - \VerbatimInput{_docshots/\jobname/\hash.tex}% + \VerbatimInput{\docshots@tmpdir/\jobname/\hash.tex}% \vspace{0pt}% \end{minipage}% \par% + \endgroup% +} + +\newcommand\docshotPrerequisite[1]{ + \iexec[log,quiet]{cp #1 \docshots@tmpdir/\jobname}% + \message{docshots: file #1 copied to + \docshots@tmpdir/\jobname/#1^^J}% +} + +\newcommand\docshotAfter[1]{ + \iexec[log,quiet]{/bin/echo -n '\detokenize{#1}' + > \docshots@tmpdir/\jobname/after.sh}% + \message{docshots: file \docshots@tmpdir/\jobname/after.sh created^^J}% } |