From 723f1351b4fcc9f483b0a91aed9b5986951462af Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 23 May 2023 19:48:22 +0000 Subject: latexdemo (23may23) git-svn-id: svn://tug.org/texlive/trunk@67200 c570f23f-e606-0410-a88d-b1316a301751 --- .../source/latex/latexdemo/latexdemo.dtx | 42 +++++++++++++--------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to 'Master/texmf-dist/source') diff --git a/Master/texmf-dist/source/latex/latexdemo/latexdemo.dtx b/Master/texmf-dist/source/latex/latexdemo/latexdemo.dtx index 436d515546e..91928b02e9c 100644 --- a/Master/texmf-dist/source/latex/latexdemo/latexdemo.dtx +++ b/Master/texmf-dist/source/latex/latexdemo/latexdemo.dtx @@ -2,11 +2,11 @@ % !TeX spellcheck = en-US % % File: latexdemo.sty -% Version: 2014/06/27 v0.1 +% Version: 2023/03/26 v0.2 % Author: Matthias Pospiech % Email: % -% Copyright (C) 2014 by Matthias Pospiech (matthias@pospiech.eu) +% Copyright (C) 2023 by Matthias Pospiech (matthias@pospiech.eu) % --------------------------------------------------------------------------- % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -32,7 +32,7 @@ %\NeedsTeXFormat{LaTeX2e}[1999/12/01] %\ProvidesPackage{latexdemo} %<*package> - [2014/06/27 v0.1 typeset code and resulting output] + [2023/03/26 v0.2 typeset code and resulting output] % % %<*driver> @@ -116,7 +116,7 @@ % code must be written to an external file. % % The commands provided by this package are based on the packages -% \package{listings}, \package{mdframed} and \package{filecontents}. +% \package{listings}, \package{mdframed} and the enviroment \environment{filecontents}. % % \section{Basic example} % \label{sec:example:basic} @@ -127,12 +127,12 @@ % \iffalse %<*example> % \fi -\begin{filecontents*}{\democodefile} +\begin{DefineCode} \so{letterspacing}, \\ \ul{underlining}, \\ \st{overstriking} \\ and \hl{highlighting}. -\end{filecontents*} +\end{DefineCode} % \iffalse % % \fi @@ -146,12 +146,12 @@ and \hl{highlighting}. %<*example> % \fi \begin{lstlisting}[style=demostyle] -\begin{filecontents*}{\democodefile} +\begin{DefineCode} \so{letterspacing}, \\ \ul{underlining}, \\ \st{overstriking} \\ and \hl{highlighting}. -\end{filecontents*} +\end{DefineCode} \ifcsdef{so}{% % @@ -173,15 +173,15 @@ and \hl{highlighting}. % \subsection{Define code} % This package requires the example code to be written to an external file. The % filename is saved in the command sequence \cs{democodefile}. The output is done -% with the \environment{filecontents} environment: +% with the \environment{DefineCode} environment: % % \iffalse %<*example> % \fi \begin{lstlisting}[style=demostyle] -\begin{filecontents*}{\democodefile} +\begin{DefineCode} ... code ... -\end{filecontents*} +\end{DefineCode} \end{lstlisting} % \iffalse % @@ -228,14 +228,14 @@ and \hl{highlighting}. %<*example> % \fi \begin{lstlisting}[style=demostyle] -\begin{filecontents*}{\democodefile} +\begin{DefineCode} This code shows some basic math: $a^2 + b^2 = c^2$. -\end{filecontents*} +\end{DefineCode} \end{lstlisting} % -\begin{filecontents*}{\democodefile} +\begin{DefineCode} This code shows some basic math: $a^2 + b^2 = c^2$. -\end{filecontents*} +\end{DefineCode} % \iffalse % % \fi @@ -341,8 +341,6 @@ This code shows some basic math: $a^2 + b^2 = c^2$. %% Programming \RequirePackage{xspace} \RequirePackage{etoolbox} -%% Write contents to files -\RequirePackage{filecontents} %% Packages for frames \RequirePackage{mdframed} \RequirePackage{framed} @@ -457,6 +455,16 @@ This code shows some basic math: $a^2 + b^2 = c^2$. % \end{macrocode} % \end{macro} % +% \begin{environment}{DefineCode} +% Define code for demonstration using the enviroment \environment{DefineCode} which is based on the enviroment \environment{filecontents*}. +% \begin{macrocode} + \newenvironment{DefineCode}{% + \csname filecontents*\endcsname[overwrite]{\democodefile}% +}{% + \csname endfilecontents*\endcsname% +} +% \end{macrocode} +% \end{environment} % % \begin{macro}{\PrintDemo} % Print code and result using the key-value syntax -- cgit v1.2.3