summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/showexpl/showexpl.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/showexpl/showexpl.dtx')
-rw-r--r--Master/texmf-dist/source/latex/showexpl/showexpl.dtx90
1 files changed, 53 insertions, 37 deletions
diff --git a/Master/texmf-dist/source/latex/showexpl/showexpl.dtx b/Master/texmf-dist/source/latex/showexpl/showexpl.dtx
index a7c3c966774..4102c6b8ddc 100644
--- a/Master/texmf-dist/source/latex/showexpl/showexpl.dtx
+++ b/Master/texmf-dist/source/latex/showexpl/showexpl.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright (C) 2004 -- 2016 by Rolf Niepraschk <Rolf.Niepraschk@gmx.de>
+% Copyright (C) 2004 -- by Rolf Niepraschk <Rolf.Niepraschk@gmx.de>
% --------------------------------------------------------------------
%
% This file may be distributed and/or modified under the
@@ -22,7 +22,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{showexpl}
%<*package>
- [2016/12/11 v0.3o Typesetting example code (RN)]
+ [2020/05/04 v0.3p Typesetting example code (RN)]
%</package>
%
%<*driver>
@@ -39,7 +39,7 @@
%</driver>
% \fi
%
-% \CheckSum{887}
+% \CheckSum{880}
%
% \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
@@ -206,6 +206,7 @@
%
% \section{Implementation}
% \changes{v0.1e}{2004/11/24}{Loading of |showexpl.cfg| added (RN).}
+% \changes{v0.3p}{2020/05/04}{Remove package `calc' (RN).}
% \begin{macrocode}
\DeclareOption{final}{%
\PassOptionsToPackage{\CurrentOption}{graphicx}%
@@ -224,7 +225,7 @@
}%
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{listings}}
\ProcessOptions\relax
-\RequirePackage{listings,calc,ifthen,graphicx,varwidth}
+\RequirePackage{refcount,listings,graphicx,varwidth,float}
% \end{macrocode}
% We must aktivate code from package \textsf{listings} for writing files.
% \begin{macrocode}
@@ -316,13 +317,12 @@
% 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).}
+% \changes{v0.3p}{2020/05/04}{Remove extra treatment of `figure'/`table' (RN).}
% \begin{macrocode}
\newcommand*\SX@@preset{%
\renewcommand\documentclass[2][]{\SX@eat@version}%
\renewcommand\usepackage[2][]{\SX@eat@version}%
\renewenvironment{document}{}{}%
- \renewenvironment{figure}[1][]{\def\@captype{figure}}{}%
- \renewenvironment{table}[1][]{\def\@captype{table}}{}%
\renewcommand\cite[1][]{}%
\let\tableofcontens\relax \let\listoffigures\relax
\let\listoftables\relax \let\printindex\relax
@@ -344,14 +344,28 @@
% \begin{macro}{\isSX@odd}
% Parameter |#1| is executed on odd pages, parameter |#2| on
% even pages.
+% \changes{v0.3p}{2020/05/04}{Replace \cmd{\isodd} with
+% \cmd{\ifodd}\cmd{\getpagerefnumber} (remove package `ifthen') (RN).}
% \begin{macrocode}
\newif\ifSX@wasodd
\if@twoside
- \newcommand*{\isSX@odd}[2]{%
- \ifthenelse{\isodd{\pageref{\SX@IDENT}}}%
- {\SX@wasoddtrue #1}{\SX@wasoddfalse #2}}
+ \newcommand*\isSX@odd{%
+ \begingroup
+ \ifodd\getpagerefnumber{\SX@IDENT}%
+ \aftergroup\SX@wasoddtrue
+ \else
+ \aftergroup\SX@wasoddfalse
+ \fi
+ \endgroup
+ \ifSX@wasodd
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi
+ }
\else
- \newcommand*{\isSX@odd}[2]{#1}\SX@wasoddtrue
+ \SX@wasoddtrue
+ \newcommand*\isSX@odd[2]{#1}
\fi
% \end{macrocode}
% The call of \cmd{\isSX@odd} sets also \cmd{\ifSX@wasodd} to true or
@@ -388,20 +402,20 @@
% \begin{macrocode}
\newcommand*\SX@put@t[3]{%
\SX@ResultArea{\linewidth}{#2}\endgraf\pagebreak[2]%
- \setlength\@tempdima{\SX@vsep}\vskip\@tempdima
+ \@tempdima=\dimexpr\SX@vsep\vskip\@tempdima
\SX@CodeArea{\linewidth}{#3}%
}
\newcommand*\SX@put@b[3]{%
\SX@CodeArea{\linewidth}{#3}\endgraf\pagebreak[2]%
- \setlength\@tempdima{\SX@vsep}\vskip\@tempdima
+ \@tempdima=\dimexpr\SX@vsep\vskip\@tempdima
\SX@ResultArea{\linewidth}{#2}%
}
\newcommand*\SX@put@l[3]{%
- \setlength\@tempdimc{\linewidth-#1-\SX@hsep}%
+ \@tempdimc=\dimexpr\linewidth-#1-\SX@hsep %
\SX@ResultArea{#1}{#2}\hfill\SX@CodeArea{\@tempdimc}{#3}%
}
\newcommand*\SX@put@r[3]{%
- \setlength\@tempdimc{\linewidth-#1-\SX@hsep}%
+ \@tempdimc=\dimexpr\linewidth-#1-\SX@hsep %
\SX@CodeArea{\@tempdimc}{#3}\hfill\SX@ResultArea{#1}{#2}%
}
\newcommand*\SX@put@o[3]{%
@@ -411,12 +425,11 @@
\@nameuse{SX@put@\ifSX@wasodd l\else r\fi}{#1}{#2}{#3}%
}
\newcommand\SX@ResultArea[2]{%
- \SX@justification\setlength\@tempdima{#1}%
- %\minipage\@tempdima#2\endminipage
+ \SX@justification\@tempdima=\dimexpr #1 %
\parbox\@tempdima{#2}%
}
\newcommand\SX@CodeArea[2]{%
- \setlength\@tempdima{#1}%
+ \@tempdima=\dimexpr #1 %
\sbox\@tempboxa{\parbox\@tempdima{#2}}%
\@tempdima=\dp\@tempboxa\usebox\@tempboxa
\rlap{\raisebox{-\@tempdima}[0pt][0pt]{\SX@attachfile}}%
@@ -477,19 +490,12 @@
\newcommand*\SX@put@code@result{%
\begingroup
\expandafter\lstset\expandafter{\SX@explpreset}%
- \let\lst@float=\relax\let\SX@float=\relax
-% \end{macrocode}
-% Without the following call \cmd{\lst@beginfloat} is undefined.
-% \begin{macrocode}
\expandafter\lstset\expandafter{\SX@@explpreset}%
- \ifx\lst@float\relax\else
% \end{macrocode}
-% \cmd{\lst@float} must be \cmd{\relax} because the whole ``example''
-% should float but not the listings part in addition.
+% Use listings floating procedure if necessary.
% \begin{macrocode}
- \let\SX@float=\lst@float\let\lst@float=\relax
- \g@addto@macro\SX@@explpreset{,float=false}%
- \edef\@tempa{\noexpand\lst@beginfloat{lstlisting}[\SX@float]}%
+ \ifx\lst@float\relax\else
+ \edef\@tempa{\noexpand\lst@beginfloat{lstlisting}[\lst@float]}
\expandafter\@tempa
\fi
\ifx\lst@caption\@empty
@@ -511,7 +517,7 @@
\ifx\@tempa\SX@pos\@tempswafalse\fi
\def\@tempa{b}%
\ifx\@tempa\SX@pos\@tempswafalse\fi
- \setlength\@tempdima{\linewidth+\SX@overhang}%
+ \@tempdima=\dimexpr\linewidth+\SX@overhang %
\if@tempswa\@tempdima=.5\@tempdima\fi%
\edef\SX@width{\the\@tempdima}%
\fi
@@ -523,12 +529,12 @@
\long\def\SX@frame##1{##1}%
\else
\let\SX@frame\ResultBox
- \setlength\@tempdima{\SX@width-2\ResultBoxSep-2\ResultBoxRule}%
+ \@tempdima=\dimexpr\SX@width-2\ResultBoxSep-2\ResultBoxRule %
\edef\SX@width{\the\@tempdima}%
\fi
\isSX@odd{\def\@tempa{l}}{\def\@tempa{r}}%
\makebox[\linewidth][\@tempa]{%
- \parbox{\linewidth+\SX@overhang}{%
+ \parbox{\dimexpr\linewidth+\SX@overhang}{%
% \end{macrocode}
% \cmd{\SX@codefile} (|\jobname.tmp|) is not nessesary for the filelist.
% \changes{v0.3m}{2016/08/05}{Wrong assignement for \cmd{\lst@belowskip} (RN).}
@@ -541,10 +547,7 @@
% true.
% \changes{v0.3k}{2013/03/21}{Setting \cmd{\lst@MakeCaption} to \cmd{\@gobble}
% again (prevent multiply defined labels; label key)}.
-% \begin{macrocode}
- \let\SX@MakeCaption\lst@MakeCaption
- \let\lst@MakeCaption\@gobble{}
-% \end{macrocode}
+% \changes{v0.3p}{2020/05/04}{Let's leave \cmd{\lst@MakeCaption} untouched (RN).}
% \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.).}
@@ -564,12 +567,11 @@
{\@latex@error{Parameter `\SX@pos' undefined}\@ehd}%
{\@nameuse{SX@put@\SX@pos}%
{\SX@width}{\box\SX@ResBox}{\SX@codeInput}}%
- \let\lst@MakeCaption\SX@MakeCaption
\lst@MakeCaption{b}\SX@KillBelowCaptionskip
}%
}%
\endtrivlist
- \ifx\SX@float\relax\else\expandafter\lst@endfloat\fi
+ \ifx\lst@float\relax\else\expandafter\lst@endfloat\fi
\gdef\SX@@explpreset{}%
\endgroup
}
@@ -693,6 +695,20 @@
\def\SX@tempb##1{\scalebox{\SX@scaled}{##1}}%
\fi
\fi
+ \let\SX@lst@Init=\lst@Init
+% \end{macrocode}
+% Prevents float environments from floating. This is not enough for floating
+% listing environments! Why?
+% \changes{v0.3p}{2020/05/04}{Better handling of floats (RN).}
+% \begin{macrocode}
+ \def\@xfloat##1[##2]{\@float@HH{##1}[H]}%
+% \end{macrocode}
+% Special handling of floating listing environments.
+% \begin{macrocode}
+ \def\lst@Init{%
+ \let\lst@float=\relax
+ \SX@lst@Init
+ }
\SX@tempb{\SX@tempa{\SX@codefile}}\par
\endgroup
\else
@@ -726,7 +742,7 @@
\fi
\SX@Info
\expandafter\lstinputlisting\expandafter[\SX@@explpreset,nolol=true,%
- caption={},belowskip=\z@,aboveskip=\z@]{\SX@codefile}%
+ caption={},belowskip=\z@,aboveskip=\z@,float=false]{\SX@codefile}%
\endgroup
}%
% \end{macrocode}