[latex3-commits] [git/LaTeX3-latex3-latex3] master: A first draw demo [ci skip] (5e29d86)

Joseph Wright joseph.wright at morningstar2.co.uk
Fri Feb 23 15:51:45 CET 2018


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/5e29d868f1d78780a160afa2fc3f4025ec518ccc

>---------------------------------------------------------------

commit 5e29d868f1d78780a160afa2fc3f4025ec518ccc
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Fri Feb 23 14:51:45 2018 +0000

    A first draw demo [ci skip]


>---------------------------------------------------------------

5e29d868f1d78780a160afa2fc3f4025ec518ccc
 l3experimental/l3draw/l3draw.dtx |   75 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)

diff --git a/l3experimental/l3draw/l3draw.dtx b/l3experimental/l3draw/l3draw.dtx
index f2620d7..1ac9038 100644
--- a/l3experimental/l3draw/l3draw.dtx
+++ b/l3experimental/l3draw/l3draw.dtx
@@ -25,6 +25,69 @@
 %</driver|package>
 %<*driver>
 \documentclass[full]{l3doc}
+\usepackage{l3draw}
+% For creating code demonstrations
+% This needs access to some code-level interfaces in listings
+\usepackage{listings}
+\makeatletter
+\lst at RequireAspects{writefile}
+\newsavebox\demo at box
+\lstnewenvironment{demo}[1][code and example]
+  {%
+    \global\let\lst at intname\@empty
+    \edef\demo at end{%
+      \expandafter\noexpand\csname demo@@#1 at end\endcsname
+    }%
+    \@nameuse{demo@@#1}%
+  }
+  {\demo at end}
+\newcommand\demo at new[3]{%
+  \@namedef{demo@@#1}{#2}%
+  \@namedef{demo@@#1 at end}{#3}%
+}
+\newcommand*\demo at common{%
+  \setkeys{lst}
+    {%
+       basicstyle   = \small\ttfamily,
+       basewidth    = 0.51em,
+       gobble       = 3,
+       language     = [LaTeX]{TeX},
+    }%
+}
+\newcommand*\demo at input{%
+  \ExplSyntaxOn
+  \catcode`\^^M = 10\relax
+  \input{\jobname.tmp}%
+  \ExplSyntaxOff
+}
+\demo at new{code and example}{%
+  \setbox\demo at box=\hbox\bgroup
+    \lst at BeginAlsoWriteFile{\jobname.tmp}%
+    \demo at common
+}{%
+    \lst at EndWriteFile
+  \egroup
+  \begin{center}
+    \ifdim\wd\demo at box > 0.67\linewidth
+      \begin{minipage}{\linewidth}
+        \usebox\demo at box
+      \end{minipage}%
+      \par
+      \begin{minipage}{\linewidth}
+        \demo at input
+      \end{minipage}
+    \else
+      \begin{minipage}{0.33\linewidth}
+        \demo at input
+      \end{minipage}%
+      \hfil
+      \begin{minipage}{0.67\linewidth}
+        \usebox\demo at box
+      \end{minipage}%
+    \fi
+  \end{center}
+}
+\makeatother
 \begin{document}
   \DocInput{\jobname.dtx}
 \end{document}
@@ -93,6 +156,18 @@
 % axes at the driver level: this is then \enquote{transparent} to the
 % \pkg{draw} level, and so should be used only when strictly required.)
 %
+% \begin{demo}
+%   \dim_new:N \l_mypos_dim
+%   \draw_begin:
+%     \draw_path_moveto:n { 0cm , \l_mypos_dim }
+%     \draw_path_lineto:n { 1cm , \l_mypos_dim }
+%     \dim_set:Nn \l_mypos_dim { 1cm }
+%     \draw_path_lineto:n { 1cm , \l_mypos_dim }
+%     \draw_path_close:
+%     \draw_path_use:n { stroke }
+%   \draw_end:
+% \end{demo}
+%
 % \subsection{Graphics state}
 %
 % Within the drawing environment, a number of functions control how drawings





More information about the latex3-commits mailing list