summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/docshots/docshots.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/docshots/docshots.dtx')
-rw-r--r--macros/latex/contrib/docshots/docshots.dtx55
1 files changed, 46 insertions, 9 deletions
diff --git a/macros/latex/contrib/docshots/docshots.dtx b/macros/latex/contrib/docshots/docshots.dtx
index 0a559d7edf..0ba48b98de 100644
--- a/macros/latex/contrib/docshots/docshots.dtx
+++ b/macros/latex/contrib/docshots/docshots.dtx
@@ -50,12 +50,13 @@
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{docshots}
%<*package>
-[2022-10-26 0.2.0 TeX Samples Next to Their PDF Snapshots in DTX]
+[2022-11-10 0.3.0 TeX Samples Next to Their PDF Snapshots in DTX]
%</package>
%<*driver>
\documentclass{ltxdoc}
\usepackage[tt=false, type1=true]{libertine}
\usepackage{microtype}
+\AddToHook{env/verbatim/begin}{\microtypesetup{protrusion=false}}
\usepackage[dtx]{docshots}
\usepackage{href-ul}
\usepackage{xcolor}
@@ -96,11 +97,11 @@
% To \href{https://tex.stackexchange.com/questions/661027}{my best}
% knowledge, there were no packages that would allow
% you do exactly this. That's why I created this simple package.
+
% For example, this code:
-%
-%\iffalse
-%<*verb>
-%\fi
+%\iffalse%
+%<*verb>%
+%\fi%
\begin{verbatim}
\begin{docshot}
\documentclass{article}
@@ -155,7 +156,7 @@
% \begin{docshot}
% \documentclass{article}
% \usepackage[paperwidth=2in,
-% paperheight=2.2in]{geometry}
+% paperheight=2.3in]{geometry}
% \begin{document}
% ``There is no sadder thing than
% a young pessimist, except an old
@@ -365,6 +366,26 @@ Hello, world!
%</verb>
%\fi
+% \section{Fine-uning Options}
+
+% \DescribeMacro{\docshotOptions}
+% By default, we render the verbatim text using |\VerbatimInput| command with
+% no options. You can add your options using |\docshotOptions| command:
+%\iffalse
+%<*verb>
+%\fi
+\begin{verbatim}
+\docshotOptions{firstline=4}
+\begin{docshot}
+...
+\end{docshot}
+\end{verbatim}
+%\iffalse
+%</verb>
+%\fi
+
+% The options will be cleaned up by the first render of a docshot.
+
% \section{Prerequisites}
% \DescribeMacro{\docshotPrerequisite}
@@ -623,17 +644,21 @@ Hello, world!
\begin{minipage}[t]{\docshots@right}%
\vspace{0pt}%
\ifdefined\docshots@lstinputlisting%
- \lstinputlisting{\docshots@tmpdir/\jobname/\hash.tex}%
+ \expandafter\lstinputlisting\expandafter[\docshots@opts]
+ {\docshots@tmpdir/\jobname/\hash.tex}%
\else\ifdefined\docshots@inputminted%
- \inputminted{\docshots@inputminted}
+ \expandafter\inputminted\expandafter[\docshots@opts]
+ {\docshots@inputminted}
{\docshots@tmpdir/\jobname/\hash.tex}%
\else%
- \VerbatimInput{\docshots@tmpdir/\jobname/\hash.tex}%
+ \expandafter\VerbatimInput\expandafter[\docshots@opts]
+ {\docshots@tmpdir/\jobname/\hash.tex}%
\fi\fi%
\vspace{0pt}%
\end{minipage}%
\par%
\endgroup%
+ \docshotOptions{}%
}\makeatother
% \end{macrocode}
% \end{macro}
@@ -661,6 +686,18 @@ Hello, world!
% \end{macrocode}
% \end{macro}
+% \begin{macro}{\docshotOptions}
+% Finally, we define |\docshotOptions| command:
+% \changes{0.3.0}{2022/11/10}{New command introduced to help specify custom options for verbatim environments.}
+% \begin{macrocode}
+\makeatletter
+\gdef\docshots@opts{}
+\newcommand\docshotOptions[1]{%
+ \gdef\docshots@opts{#1}%
+}\makeatother
+% \end{macrocode}
+% \end{macro}
+
% \Finale
%\clearpage