From c4fc9d799a82b2e62e2c7982a6e461d3a7fea717 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 20 Jan 2014 23:17:40 +0000 Subject: showexpl (20jan14) git-svn-id: svn://tug.org/texlive/trunk@32737 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/source/latex/showexpl/showexpl.dtx | 136 ++++++++++++--------- 1 file changed, 77 insertions(+), 59 deletions(-) (limited to 'Master/texmf-dist/source/latex/showexpl/showexpl.dtx') diff --git a/Master/texmf-dist/source/latex/showexpl/showexpl.dtx b/Master/texmf-dist/source/latex/showexpl/showexpl.dtx index 3eb49722fda..78d41e731f4 100644 --- a/Master/texmf-dist/source/latex/showexpl/showexpl.dtx +++ b/Master/texmf-dist/source/latex/showexpl/showexpl.dtx @@ -2,7 +2,7 @@ % % Copyright (C) 2004 -- 2006 by Rolf Niepraschk % -------------------------------------------------------------------- -% +% % This file may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.2 % of this license or (at your option) any later version. @@ -10,7 +10,7 @@ % % http://www.latex-project.org/lppl.txt % -% and version 1.2 or later is part of all distributions of LaTeX +% and version 1.2 or later is part of all distributions of LaTeX % version 1999/12/01 or later. % % \fi @@ -22,7 +22,7 @@ %\NeedsTeXFormat{LaTeX2e}[1999/12/01] %\ProvidesPackage{showexpl} %<*package> - [2013/03/21 v0.3k Typesetting example code (RN)] + [2014/01/19 v0.3l Typesetting example code (RN)] % % %<*driver> @@ -39,7 +39,7 @@ % % \fi % -% \CheckSum{845} +% \CheckSum{870} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -92,7 +92,7 @@ % \DoNotIndex{\parbox,\setbox,\setlength,\hfill,\item,\number} % \DoNotIndex{\x} % \DoNotIndex{\SX@put@a,\SX@put@b,\SX@put@l,\SX@put@r,\SX@put@o,\SX@put@i} -% +% % ^^A\DoNotIndex{\usepackage,\documentclass,\tableofcontens,\printindex} % % \title{The \textsf{showexpl} package\thanks{This document @@ -114,32 +114,32 @@ % \section{Usage} % % You can use \textsf{showexpl} like every other package by putting the -% line +% line % \begin{verbatim} -% \usepackage{showexpl} +% \usepackage{showexpl} % \end{verbatim} % \vspace{-\baselineskip} % in your source code. \textsf{showexpl} doesn't know any options by -% itself, but all options for the underlying packages -% (\textsf{listings} and \textsf{graphicx}) will be passed to the +% itself, but all options for the underlying packages +% (\textsf{listings} and \textsf{graphicx}) will be passed to the % respective packages. % % \textsf{showexpl} provides one command and one environment: % \begin{itemize} % \item |\LTXinputExample| and % \item \textsf{LTXexample} -% \end{itemize} +% \end{itemize} % % \DescribeMacro{\LTXinputExample} % The syntax of |\LTXinputExample| is given by % \begin{quote} -% |\LTXinputExample[|\meta{key val list}|]{|\meta{file}|}| +% |\LTXinputExample[|\meta{key val list}|]{|\meta{file}|}| % \end{quote} -% +% % \DescribeEnv{LTXexample} % The syntax of the environment \textsf{LTXexample} is given by % \begin{quote} -% |\begin{LTXexample}[|\meta{key val list}|]|\ldots|\end{LTXexample}| +% |\begin{LTXexample}[|\meta{key val list}|]|\ldots|\end{LTXexample}| % \end{quote} % % The set of options represented by \meta{key val list} is the same for @@ -154,7 +154,7 @@ % \item[explpreset] A \meta{key val list} which serves for presetting the % properties of the formatting of the source code, for values see the % documentation of the \textsf{listings} package. The default value is -% +% % \item[graphic] Name of a (graphic) file. This file---if present---will % be included and displayed instead of the formatted code. The default value is empty. % \item[hsep] Defines the horizontal distance between the source code and the @@ -170,13 +170,13 @@ % |o|, and |i| for top, bottom, left, right, outer, and inner. The last % values give sense only for two-sided printing, where there are outer % and inner margins of a page. The default value is |l|. -% \item[preset] Any \TeX\ code executed before the sample code but +% \item[preset] Any \TeX\ code executed before the sample code but % not visible in the listings area. % \item[rangeaccept] Boolean valued key, default value is false. If set % to true, one can define ranges of lines that will be excerpted from % the source code. % \item[rframe] Defines the form of the frame around the formatted -% text. With a non-empty value (e.\,g. ``single'') a simple frame +% text. With a non-empty value (e.\,g. ``single'') a simple frame % will be drawn. In the future more kinds of frames will be supported. % The default value is empty (no frame). % \item[varwidth] Boolean valued key, default value is false. If set to @@ -190,6 +190,9 @@ % \item[width] A \meta{dimen} value that defines the width of the % formatted text. The default value depends of the relative positions of % the source code and the formatted text. +% \item[scaled] Without a value the formatted text will be scaled to fit +% the given width of the result area. With a number as value the formatted +% text will be scaled by this number. % \end{description} % % \StopEventually{} @@ -228,11 +231,11 @@ \newcommand*\SX@defaultWD[2]{% \afterassignment\SX@def@WD\dimen@#2\linewidth\relax{#1}} \newcommand*\SX@def@WD{} -\def\SX@def@WD#1\relax#2{\edef#2{\the\dimen@}} +\def\SX@def@WD#1\relax#2{\edef#2{\the\dimen@}} % \end{macrocode} % \end{macro} % Additional keys. -% \changes{v0.1a}{2004/11/14}{``hpos'' and ``vpos'' added, +% \changes{v0.1a}{2004/11/14}{``hpos'' and ``vpos'' added, % ``pos'' removed (RN).} % \changes{v0.1f}{2004/12/06}{``lstpreset'' added. (RN).} % \changes{v0.1h}{2005/06/03}{``codefile'' added. (RN).} @@ -245,8 +248,13 @@ \lst@Key{wide}f[t]{\lstKV@SetIf{#1}\if@SX@wide} \lst@Key{rframe}\relax{\def\SX@rframe{#1}} \lst@Key{preset}\relax{\def\SX@preset{#1}} +\newcommand*\SX@scaled{} +\lst@Key{scaled}{?}[!]{\def\SX@scaled{#1}} % \end{macrocode} -% \changes{v0.1h}{2005/06/03}{``lstpreset'' renamed to ``explpreset'' (RN).} +% \changes{v0.1h}{2005/06/03}{``lstpreset'' renamed to ``explpreset'' +% (RN).} +% \changes{v0.3l}{2014/01/19}{Option ``scaled'' and \cmd{\SX@scaled} +% added (RN).} % \begin{macrocode} \lst@Key{explpreset}\relax{\def\SX@explpreset{#1}} \lst@Key{codefile}\relax{\def\SX@codefile{#1}} @@ -284,7 +292,7 @@ \newcommand\SX@preset{} \newcommand*\SX@explpreset{} % \end{macrocode} -% \changes{v0.3g}{2006/09/05}{Missing \cmd{\newcommand} for +% \changes{v0.3g}{2006/09/05}{Missing \cmd{\newcommand} for % \cmd{\SX@@explpreset} added (RN).} % \begin{macrocode} \newcommand*\SX@@explpreset{} @@ -293,11 +301,11 @@ % \end{macrocode} % \begin{macro}{\SX@@preset} % Contains some redefinitions of \LaTeX\ macros and environments to do -% nothing. \cmd{\SX@@preset} will be called just before -% typesetting the result of the example code. More can be added with +% nothing. \cmd{\SX@@preset} will be called just before +% typesetting the result of the example code. More can be added with % the user key ``|preset=...|''. % \changes{v0.3e}{2006/04/05}{More redefinitions added (RN).} -% \begin{macrocode} +% \begin{macrocode} \newcommand*\SX@@preset{% \renewcommand\documentclass[2][]{\SX@eat@version}% \renewcommand\usepackage[2][]{\SX@eat@version}% @@ -323,8 +331,8 @@ % \end{macrocode} % \end{macro} % \begin{macro}{\isSX@odd} -% Parameter |#1| is executed on odd pages, parameter |#2| on -% even pages. +% Parameter |#1| is executed on odd pages, parameter |#2| on +% even pages. % \begin{macrocode} \newif\ifSX@wasodd \if@twoside @@ -335,7 +343,7 @@ \newcommand*{\isSX@odd}[2]{#1}\SX@wasoddtrue \fi % \end{macrocode} -% The call of \cmd{\isSX@odd} sets also \cmd{\ifSX@wasodd} to true or +% The call of \cmd{\isSX@odd} sets also \cmd{\ifSX@wasodd} to true or % false. If it's clear that no page break occurs, \cmd{\ifSX@wasodd} % can be used. % \begin{macrocode} @@ -344,7 +352,7 @@ % \end{macrocode} % \end{macro} % \begin{macro}{\SX@attachfile} -% \changes{v0.3a}{2005/08/20}{Attach file functionality (with pdf\TeX) +% \changes{v0.3a}{2005/08/20}{Attach file functionality (with pdf\TeX) % added (RN).} % \begin{macrocode} \newcommand*\SX@attachfile{% @@ -357,13 +365,13 @@ % \end{macro} % \begin{macro}{\SX@put@t/b/l/r/o/i} % Six macros for positioning |#2| (result) and |#3| (code). The result -% can be -% \underline{a}bove, \underline{b}elow, \underline{l}eft or -% \underline{r}ight of the code area or on the \underline{o}uter or +% can be +% \underline{a}bove, \underline{b}elow, \underline{l}eft or +% \underline{r}ight of the code area or on the \underline{o}uter or % \underline{i}nner side. Parameter |#1| is the width of the result. -% \changes{v0.1b}{2004/11/18}{Positioning the captions more independend +% \changes{v0.1b}{2004/11/18}{Positioning the captions more independend % of the result and code area (RN).} -% \changes{v0.1c}{2004/11/19}{Commands \cmd{\SX@KillAboveCaptionskip} and +% \changes{v0.1c}{2004/11/19}{Commands \cmd{\SX@KillAboveCaptionskip} and % \cmd{\SX@KillBelowCaptionskip} added (RN).} % \changes{v0.1k}{2005/06/13}{Change [a]bove to [t]op (RN).} % \begin{macrocode} @@ -416,7 +424,7 @@ } % \end{macrocode} % \end{macro} -% +% % \begin{environment}{LTXexample} % \changes{v0.1h}{2005/06/03}{Renamed from ``example'' to ``LTXexample' (RN).} % \begin{macrocode} @@ -425,10 +433,10 @@ \@temptokena{#1}% \begingroup % \end{macrocode} -% For "codefile=..."/"graphic=..." if \cmd{\theltxexample} or +% For "codefile=..."/"graphic=..." if \cmd{\theltxexample} or % \cmd{\thelstlisting} is part of the filename. % \begin{macrocode} - \advance\c@ltxexample\@ne \advance\c@lstlisting\@ne + \advance\c@ltxexample\@ne \advance\c@lstlisting\@ne \expandafter\lstset\expandafter{\SX@explpreset,#1}% \edef\x{\endgroup \def\noexpand\SX@codefile{\SX@codefile}% @@ -446,12 +454,12 @@ } % \end{macrocode} % \end{environment} -% \changes{v0.1i}{2005/06/07}{Better caption positioning and +% \changes{v0.1i}{2005/06/07}{Better caption positioning and % correct distance between the parts (RN).} % \changes{v0.1m}{2005/06/25}{Problem related to \cmd{\label}/\cmd{\ref} % solved (RN).} % \changes{v0.2a}{2005/07/16}{``varwidth'' package used (RN).} -% \changes{v0.2b}{2005/07/30}{Check if \cmd{\SX@put@}\texttt{?} +% \changes{v0.2b}{2005/07/30}{Check if \cmd{\SX@put@}\texttt{?} % is defined (RN).} % \begin{macro}{\SX@put@code@result} % \begin{macrocode} @@ -465,7 +473,7 @@ \expandafter\lstset\expandafter{\SX@@explpreset}% \ifx\lst@float\relax\else % \end{macrocode} -% \cmd{\lst@float} must be \cmd{\relax} because the whole ``example'' +% \cmd{\lst@float} must be \cmd{\relax} because the whole ``example'' % should float but not the listings part in addition. % \begin{macrocode} \let\SX@float=\lst@float\let\lst@float=\relax @@ -480,11 +488,11 @@ \trivlist\item\relax \stepcounter{ltxexample}\label{\SX@IDENT}% % \end{macrocode} -% Make \cmd{\SX@width} a real dimension if the unit is missing. +% Make \cmd{\SX@width} a real dimension if the unit is missing. % \begin{macrocode} \SX@defaultWD\SX@width{\SX@width}% % \end{macrocode} -% Set the default width if necessary. +% Set the default width if necessary. % \begin{macrocode} \ifdim\SX@width<\z@ \@tempswatrue @@ -497,7 +505,7 @@ \edef\SX@width{\the\@tempdima}% \fi % \end{macrocode} -% Correct \cmd{\SX@width} if a frame is requested. +% Correct \cmd{\SX@width} if a frame is requested. % \begin{macrocode} \ifx\SX@rframe\@empty \long\def\SX@frame##1{##1}% @@ -511,13 +519,13 @@ \parbox{\linewidth+\SX@overhang}{% % \end{macrocode} % \cmd{\SX@codefile} (|\jobname.tmp|) is not nessesary for the filelist. -% \begin{macrocode} +% \begin{macrocode} \let\@addtofilelist\@gobble \let\lst@ifdisplaystyle=\iftrue \SX@KillAboveCaptionskip\lst@MakeCaption{t}% \lst@belowskip=\z@ % \end{macrocode} -% Use the ``natural'' width of the result code if ``varwidth'' is +% Use the ``natural'' width of the result code if ``varwidth'' is % true. % \changes{v0.3k}{2013/03/21}{Setting \cmd{\lst@MakeCaption} to \cmd{\@gobble} % again (prevent multiply defined labels; label key)}. @@ -525,8 +533,8 @@ \let\SX@MakeCaption\lst@MakeCaption \let\lst@MakeCaption\@gobble{} % \end{macrocode} -% \changes{v0.3j}{2012/09/22}{Setting \cmd{\lst@MakeCaption} to -% was a bad idea for hyperlinks. Group added to +% \changes{v0.3j}{2012/09/22}{Setting \cmd{\lst@MakeCaption} to +% was a bad idea for hyperlinks. Group added to % varwidth environment. (Suggestions by Ulrike Fischer.).} % \begin{macrocode} \setbox\SX@ResBox\hbox{% @@ -553,9 +561,9 @@ } % \end{macrocode} % \end{macro} -% \changes{v0.3g}{2006/09/05}{\cmd{\SX@ProcessResult} is now working +% \changes{v0.3g}{2006/09/05}{\cmd{\SX@ProcessResult} is now working % correctly -% using \cmd{\readline} and \cmd{\scantokens}. Thanks to Ulrich Diez +% using \cmd{\readline} and \cmd{\scantokens}. Thanks to Ulrich Diez % for help (RN).} % \begin{macrocode} \newcommand\SX@SkipToFirst{% @@ -593,7 +601,7 @@ % \end{macrocode} % \begin{macro}{\SX@input} % \changes{v0.1j}{2005/06/12}{For ranges of lines (RN).} -% \begin{macrocode} +% \begin{macrocode} \newcommand\SX@input[1]{% \begingroup \IfFileExists{#1}{}% @@ -619,8 +627,8 @@ \endgroup } % \end{macrocode} -% \end{macro} -% \begin{macrocode} +% \end{macro} +% \begin{macrocode} \newcommand*\SX@Info{% \typeout{--------------------------------}% \typeout{pos=\SX@pos}% @@ -646,10 +654,11 @@ \providecommand*\MakePercentComment{\catcode`\%14\relax} % \end{macrocode} % \begin{macro}{\SX@resultInput} -% \changes{v0.3b}{2005/10/15}{Input of result code now inside a group; +% \changes{v0.3b}{2005/10/15}{Input of result code now inside a group; % \cmd{\makeatother} added (RN).} % \changes{v0.3c}{2005/10/15}{Wrong catcode for newline char corrected (RN).} % \changes{v0.3d}{2005/12/06}{Missing \cs{par} added (RN).} +% \changes{v0.3l}{2014/01/19}{Code for ``scaled'' option (RN).} % \begin{macrocode} \newcommand*\SX@resultInput{% \ifx\SX@graphicname\@empty @@ -661,7 +670,16 @@ \else \let\SX@tempa=\input \fi - \SX@tempa{\SX@codefile}\par% + \if\SX@scaled ?% + \let\SX@tempb=\@firstofone + \else + \if\SX@scaled !% + \def\SX@tempb##1{\resizebox{\SX@width}{!}{##1}}% + \else + \def\SX@tempb##1{\scalebox{\SX@scaled}{##1}}% + \fi + \fi + \SX@tempb{\SX@tempa{\SX@codefile}}\par \endgroup \else \expandafter\includegraphics\expandafter[\SX@graphicparam]% @@ -674,19 +692,19 @@ % \begin{macrocode} \newcommand*\SX@codeInput{% % \end{macrocode} -% Without a caption entry the command \cmd{\lstinputlisting} adds the -% filename to the ``list of listings'' (lol). This should be avoided. +% Without a caption entry the command \cmd{\lstinputlisting} adds the +% filename to the ``list of listings'' (lol). This should be avoided. % \changes{v0.1d}{2004/11/20}{\cmd{\lstset}|{nolol}| and % \cmd{\lstset}|{float=false}| added (RN).} % \changes{v0.1h}{2005/06/03}{\cmd{\lstset}|{float=false}| removed (RN).} % \begin{macrocode} \begingroup % \end{macrocode} -% The default parameters for all examples. -% \begin{macrocode} +% The default parameters for all examples. +% \begin{macrocode} \expandafter\lstset\expandafter{\SX@explpreset}% % \end{macrocode} -% If "numbers=none" then margin dimensions should be zero. +% If "numbers=none" then margin dimensions should be zero. % \begin{macrocode} \expandafter\lstset\expandafter{\SX@@explpreset}% \ifx\lst@PlaceNumber\@empty @@ -701,7 +719,7 @@ % \end{macro} % \changes{v0.1h}{2005/06/03}{New macro \cmd{\LTXinputExample} (RN).} % \begin{macrocode} -\newcommand*\LTXinputExample[2][]{% +\newcommand*\LTXinputExample[2][]{% \g@addto@macro\SX@@explpreset{#1,codefile=#2}% \SX@put@code@result}% % \end{macrocode} @@ -721,7 +739,7 @@ \def\theHlstnumber{\thelstlisting.\arabic{lstnumber}.\lst@neglisting}% } % \end{macrocode} -% \changes{v0.1g}{2004/12/10}{Loading of |showexpl.cfg| now at end of +% \changes{v0.1g}{2004/12/10}{Loading of |showexpl.cfg| now at end of % package (RN).} % Changing the defaults possible in |showexpl.cfg|. % \begin{macrocode} -- cgit v1.2.3