diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/listings/listings.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/listings/listings.dtx | 124 |
1 files changed, 109 insertions, 15 deletions
diff --git a/Master/texmf-dist/source/latex/listings/listings.dtx b/Master/texmf-dist/source/latex/listings/listings.dtx index c63ef2ffab3..1874a178496 100644 --- a/Master/texmf-dist/source/latex/listings/listings.dtx +++ b/Master/texmf-dist/source/latex/listings/listings.dtx @@ -22,7 +22,7 @@ % % The listings package and its drivers may be distributed and/or modified % under the conditions of the LaTeX Project Public License, either version -% 1.3 of this license or (at your option) any later version. +% 1.3c of this license or (at your option) any later version. % The latest version of this license is in % http://www.latex-project.org/lppl.txt % and version 1.3c or later is part of all distributions of LaTeX @@ -96,8 +96,8 @@ %\lstisaspect[kernel]{basewidth,fontadjust,columns,flexiblecolumns,identifierstyle,^^A % tabsize,showtabs,tab,showspaces,keepspaces,formfeed,SelectCharTable,^^A % MoreSelectCharTable,extendedchars,alsoletter,alsodigit,alsoother,excludedelims,^^A -% literate,basicstyle,print,firstline,lastline,linerange,nolol,captionpos,^^A -% abovecaptionskip,^^A +% literate,basicstyle,print,firstline,lastline,linerange,^^A +% consecutivenumbers,nolol,captionpos,abovecaptionskip,^^A % belowcaptionskip,label,title,caption,\string\lstlistingname,^^A % \string\lstlistingnamestyle,boxpos,float,^^A % floatplacement,aboveskip,belowskip,everydisplay,showlines,emptylines,gobble,name,^^A @@ -133,7 +133,7 @@ % Hoffmann became the maintainer of the \packagename{listings} % package in 2013; see the Preface for details.}~ % % \textless\lstemail\textgreater} -% \date{2019/09/10\enspace\enspace Version 1.8c\ \box\abstractbox} +% \date{2020/03/24\enspace\enspace Version 1.8d\ \box\abstractbox} % \def\lstemail{\href{mailto:j.hoffmann@fh-aachen.de}{\texttt{j.hoffmann(at)fh-aachen.de}}} % \ifhyper % \hypersetup{pdftitle=The Listings Package, @@ -727,7 +727,7 @@ % \paragraph{Distribution and modification} % The \packagename{listings} package and its drivers may be distributed % and/or modified under the conditions of the LaTeX Project Public License, -% either version 1.3 of this license or (at your option) any later version. +% either version 1.3c of this license or (at your option) any later version. % The latest version of this license is in % \href{http://www.latex-project.org/lppl.txt}{http://www.latex-project.org/lppl.txt} % and version 1.3c or later is part of all distributions of LaTeX version @@ -1106,6 +1106,58 @@ % \end{lstsample} % The next |Test| listing goes on with line number {\makeatletter\lstno@Test}, % no matter whether there are other listings in between. +% +% You can also select the lines to be printed, the options +% `\ikeyname{linerange}' and `\ikeyname{consecutivenumbers}' are your +% friend. In a presentation for example you don't need comments for your +% programs, so you prefer the line numbers being consecutively numbered, +% but the results should reflect the behaviour of the program---you omit +% parts of the lengthy output. So +% you may have the following program and its results. +% \begin{lstsample}[name]{\lstset{numbers=left,numberstyle=\tiny,stepnumber=1,numbersep=5pt}}{} +% \begin{lstlisting}[name=Test, +% language={[ansi]C}, +% linerange={1-4,6-7,10-14, +% 17-19,21-22}, +% firstnumber=1] +% #include <stdio.h> +% #include <stdlib.h> +% +% int main(int argc,char* argv[]){ +% /* declaring variables */ +% int i; +% int limit; +% +% /* checking arguments */ +% if ( argc > 1 ) { +% limit = atoi(argv[1]); +% } else { +% limit = 100; +% } +% +% /* counting lines */ +% for (i = 1;i <= limit;i++) { +% printf("Line no. %3.0d\n", i); +% } +% +% return 0; +% } +% +% \end{lstlisting} +% And these are the results: +% \begin{lstlisting}[language={}, +% linerange={1-2,6-7}, +% consecutivenumbers=false] +% Line no. 1 +% Line no. 2 +% Line no. 3 +% Line no. 4 +% Line no. 5 +% Line no. 6 +% Line no. 7 +% \end{lstlisting} +% \end{lstsample} +% % \begin{advise} % \item Okay. And how can I get decreasing line numbers? % \advisespace @@ -2294,6 +2346,16 @@ % listing are displayed. The intervals must be sorted and must not % intersect. % +% \item[1.8, true] +% \rkeyname{consecutivenumbers}|=|\meta{\alternative{true,false}}^^A +% \syntaxor\rkeyname{consecutivenumbers}\label{uoption:consecutivenumbers} +% +% can be used on individual listings only. Its use makes sense only if +% also \rkeyname{linerange} is used. The default (true) value means that +% the line numbering for \emph{all} lineranges happens to be consecutively, +% e\,g. 1, 2, 3,\ldots. If it is set to false, different ranges get +% their own numbering (see sec. \ref{uLineNumbers}). +% % \item[0.20,false] % \rkeyname{showlines}|=|\meta{\alternative{true,false}}\syntaxor\rkeyname{showlines} % @@ -2640,7 +2702,7 @@ % the number corresponding to the first input line. % % \texttt{last} continues the numbering of the most recent listing and -% \meta{number} sets it to the number. +% \meta{number} sets it to the (logical) number. % % \item[1.0] \rkeyname{name}|=|\meta{name} % @@ -3984,6 +4046,10 @@ % \item[1.2,true] \rkeyname{includerangemarker}|=|\meta{\alternative{true,false}} % % shows or hides the markers in the output. +% +% \textbf{Remark:} If |firstnumber| is set, it refers to +% the line which contains the marker. So if one wants to start a range with +% the number 1, one has to set |includerangemarker=false, firstnumber=0|. % \end{syntax} % \begin{lstsample}{\lstset{rangeprefix=\{\ ,rangesuffix=\ \}}}{} % \begin{lstlisting}% @@ -4357,7 +4423,7 @@ % \end{advise} % First of all, you'll need Metafont source files for bold typewriter, e.g.~ % \texttt{cmbtt8.mf}, \texttt{cmbtt9.mf} and \texttt{cmbtt10.mf} from -% \href{ftp://ftp.dante.de/tex-archive/fonts/cm/mf-extra/bold} +% \href{http://mirror.ctan.org/fonts/cm/mf-extra/bold} % {CTAN/fonts/cm/mf-extra/bold}. % Secondly you have to create \texttt{.tfm}-files, i.e.~run the Metafont % program on these sources. This is possibly done automatically when you use @@ -5843,7 +5909,7 @@ % \part{Implementation} % % -% \CheckSum{12380} +% \CheckSum{12394} %^^A %^^A Don't index TeX-primitives. %^^A @@ -5987,8 +6053,8 @@ % All files will have same date and version. % \begin{macrocode} %<*kernel|misc|doc> -\def\filedate{2019/09/10} -\def\fileversion{1.8c} +\def\filedate{2020/03/24} +\def\fileversion{1.8d} %</kernel|misc|doc> % \end{macrocode} % What we need and who we are. @@ -8775,7 +8841,15 @@ \lst@ProcessOther {"27}{\lst@ifupquote \textquotesingle \else \char39\relax \fi} \lst@ProcessOther {"2A}{\lst@ttfamily*\textasteriskcentered} - \lst@ProcessOther {"2D}{\lst@ttfamily{-{}}{$-$}} +% \end{macrocode} +% \lsthelper{Ulrike~Fischer}{2020/02/19}{Inkompabilität von breqn/flexisym +% mit listings} pointed out the incompatibility between +% \packagename{flexisym} and \packagename{listings}: \packagename{flexisym} +% changes the math code while \packagename{listings} changes the +% meaning. So the minus character vanishes. Replacing the original |$-$| by +% |\textminus| should remedy the problem. +% \begin{macrocode} + \lst@ProcessOther {"2D}{\lst@ttfamily{-{}}{\textminus}} \lst@ProcessOther {"3C}{\lst@ttfamily<\textless} \lst@ProcessOther {"3E}{\lst@ttfamily>\textgreater} \lst@ProcessOther {"5C}{\lst@ttfamily{\char92}\textbackslash} @@ -13638,6 +13712,7 @@ % line ranges with numbers and range markers. It uses some more keys: % % \begin{lstkey}{linerange} +% \begin{lstkey}{consecutivenumbers} % \begin{lstkey}{rangeprefix} % \begin{lstkey}{rangesuffix} % \begin{lstkey}{rangebeginprefix} @@ -13649,6 +13724,9 @@ % \begin{macrocode} \lst@Key{linerange}\relax{\lstKV@OptArg[]{#1}{% \def\lst@interrange{##1}\def\lst@linerange{##2,}}} +% \end{macrocode} +% +% \begin{macrocode} \lst@Key{rangeprefix}\relax{\def\lst@rangebeginprefix{#1}% \def\lst@rangeendprefix{#1}} \lst@Key{rangesuffix}\relax{\def\lst@rangebeginsuffix{#1}% @@ -13727,7 +13805,7 @@ % \end{macrocode} % \end{lstkey}\end{lstkey}\end{lstkey} % \end{lstkey}\end{lstkey}\end{lstkey} -% \end{lstkey}\end{lstkey} +% \end{lstkey}\end{lstkey}\end{lstkey} % % Actually defining the marker (via |\lst@GLI@|, |\lst@DefRange|, % |\lst@CArgX| as seen above) is similar to |\lst@DefDelimB|---except that @@ -14738,7 +14816,9 @@ % package, which is part of |doc.dtx| from the Standard \LaTeX\ documentation % package, version 2006/02/02 v2.1d. Portions of it are thus copyright % 1993--2006 by The \LaTeX3 Project and copyright 1989--1999 by Frank -% Mittelbach. +% Mittelbach. \lsthelper{Denis~Bitouz\'e}{2020/03/21} +% {Typos in error messages} used the Corona crisis to have look at the +% error messages and found some typos. % % \begin{macro}{\lstMakeShortInline} % \begin{macro}{\lstMakeShortInline@} @@ -15023,11 +15103,21 @@ % We just look whether to drop more lines or to leave the mode which restores % the definition of chr(13) and chr(10). % \begin{macrocode} + \lst@Key{consecutivenumbers}{true}[t]{\lstKV@SetIf{#1}\lst@ifconsecutivenumbers} + \def\lst@DisplayConsecutiveNumbersOrNot{% + \lst@ifconsecutivenumbers\typeout{consecutive:}\else% + \typeout{non-consecutive:} + \c@lstnumber=\numexpr-1+\lst@lineno %\relax % this enforces the + %displayed line numbers to always be the + %input line numbers + \fi% +} \def\lst@MSkipToFirst{% \global\advance\lst@lineno\@ne \ifnum \lst@lineno=\lst@firstline \lst@LeaveMode \global\lst@newlines\z@ \lsthk@InitVarsBOL + \lst@DisplayConsecutiveNumbersOrNot \expandafter\lst@BOLGobble \fi} % \end{macrocode} @@ -15335,9 +15425,13 @@ % \lsthelper{Karl~Berry}{2018/10/26}{listings 1.7 \rcmdname\leavevmode -> blank line} and % \lsthelper{Sven~Schreiber}{2018/10/23}{Geändertes Verhalten in der neuen listings-Version} reported % independently, so the proposed code goes into the second part of the -% environment definition +% environment definition. \lsthelper{Enrico Gregorio}{2019/05/04}{Is it a +% listings package bug?} answered on +% \url{https://tex.stackexchange.com/questions/489121/is-it-a-listings-package-bug} +% that the previous solution |\let\if@nobreak\iffalse| is wrong because it +% is a local assignment, but a globally setting is needed. % \begin{macrocode} - \let\if@nobreak\iffalse% + \@nobreakfalse \csname\@lst @SaveFirstNumber\endcsname% } % \end{macrocode} |