diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/cnltx/cnltx-example.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/cnltx/cnltx-example.sty | 228 |
1 files changed, 154 insertions, 74 deletions
diff --git a/Master/texmf-dist/tex/latex/cnltx/cnltx-example.sty b/Master/texmf-dist/tex/latex/cnltx/cnltx-example.sty index 39d066602fd..c7b39b03c77 100644 --- a/Master/texmf-dist/tex/latex/cnltx/cnltx-example.sty +++ b/Master/texmf-dist/tex/latex/cnltx/cnltx-example.sty @@ -8,7 +8,7 @@ % Web: https://github.com/cgnieder/cnltx/ % E-Mail: contact@mychemistry.eu % -------------------------------------------------------------------------- -% Copyright 2013-2015 Clemens Niederberger +% Copyright 2013--2019 Clemens Niederberger % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -101,10 +101,15 @@ {\cnltx@key@aux{#1}\Marg}% } - +\newlength\cnltx@choice@sep@stretch +\setlength\cnltx@choice@sep@stretch{\z@\@plus.5em} % \DeclareListParser*\cnltx@choices{|} \newrobustcmd*\choices[1]{% - \def\cnltx@choice@sep{\def\cnltx@choice@sep{|\hskip\z@}}% + \def\cnltx@choice@sep{% + \def\cnltx@choice@sep{% + \hskip\cnltx@choice@sep@stretch|\hskip\cnltx@choice@sep@stretch + }% + }% \forcsvlist{\cnltx@choice@sep\code}{#1}% } @@ -229,9 +234,8 @@ {Ä}{{\"A}}{1} {Ö}{{\"O}}{1} {Ü}{{\"U}}{1} - {ß}{{\ss}}{1} - {`}{\`{}}{1} - {'}{\textquotesingle}{1} , + {ß}{{\ss}}{1} , + upquote = true, breaklines = true, keepspaces = true, breakindent = 1em, @@ -260,9 +264,11 @@ equation,eqnarray, figure,flushleft,flushright, itemize,list, + math, otherlanguage, table,tabu,tabular }, + texcs = , keywords = , % \begin, \end: texcsstyle = [2]\color{beginend}, index = [2][texcs2], @@ -277,12 +283,12 @@ index = [4][texcs4], indexstyle = [4]\@gobble, % added environments that'll be indexed: - texcsstyle = [5]\color{env}, - index = [5][texcs5], + keywordstyle = [5]\color{env}, + index = [5][keyword5], indexstyle = [5]\indexenv, % environments that won't be indexed: - texcsstyle = [6]\color{env}, - index = [6][texcs6], + keywordstyle = [6]\color{env}, + index = [6][keyword6], indexstyle = [6]\@gobble, moredelim = *[s][\color{math}]{$}{$} } @@ -304,6 +310,7 @@ {Ö}{{\"O}}1 {Ü}{{\"U}}1 {ß}{{\ss}}1 , + upquote = true, breaklines = true, keepspaces = true, breakindent = 1em, @@ -311,6 +318,9 @@ keywordstyle = \color{bibentry} , keywordstyle = [2]\color{bibentryfield}\itshape , showstringspaces = false , + deleteindex = [3][texcs3] , + deleteindex = [5][keyword5] , + deleteindex = [6][keyword6] } \def\cnltx@makeindex@listings@style{ @@ -337,8 +347,49 @@ keywordstyle = \color{makeidxkey}\bfseries , stringstyle = \color{makeidxstring} , showstringspaces = false , + deleteindex = [3][texcs3] , + deleteindex = [5][keyword5] , + deleteindex = [6][keyword6] +} + +\def\cnltx@bash@listings@style{ + language = bash, + basicstyle = {\sourceformat\color{black}}, + % numbers = left, + % numberstyle = \tiny, + xleftmargin = 1em, + numbersep = .75em, + gobble = \cnltx@gobble , + columns = fullflexible, + literate = + {ä}{{\"a}}1 + {ö}{{\"o}}1 + {ü}{{\"u}}1 + {Ä}{{\"A}}1 + {Ö}{{\"O}}1 + {Ü}{{\"U}}1 + {ß}{{\ss}}1 , + upquote = true, + breaklines = true, + keepspaces = true, + breakindent = 1em, + commentstyle = \color{comment}, + keywordstyle = \color{black}\bfseries , + stringstyle = \color{black} , + showstringspaces = false , + morekeywords = texdoc , + deleteindex = [3][texcs3] , + deleteindex = [5][keyword5] , + deleteindex = [6][keyword6] } +\newcommand*\cnltx@prompt{} +\patchcmd\lst@NewLine + {\hbox{}} + {\hbox{}\cnltx@prompt} + {} + {} + \cnltx@expandargs(nx)\lstdefinestyle {cnltx} {\expandonce\cnltx@listings@style} @@ -351,6 +402,10 @@ {cnltx-makeindex} {\expandonce\cnltx@makeindex@listings@style} +\cnltx@expandargs(nx)\lstdefinestyle + {bash} + {\expandonce\cnltx@bash@listings@style} + \lstdefinestyle {cnltx-inline} { @@ -381,18 +436,18 @@ \def\cnltx@addenvs#1{% \cnltx@expandargs(nx)\lstdefinestyle {cnltx} - {\expandonce\cnltx@listings@style,\unexpanded{moretexcs={[5]#1}}}% + {\expandonce\cnltx@listings@style,\unexpanded{morekeywords={[5]#1}}}% \edef\cnltx@listings@style{% - \expandonce\cnltx@listings@style,\unexpanded{moretexcs={[5]#1}}% + \expandonce\cnltx@listings@style,\unexpanded{morekeywords={[5]#1}}% }% } \def\cnltx@addsilentenvs#1{% \cnltx@expandargs(nx)\lstdefinestyle {cnltx} - {\expandonce\cnltx@listings@style,\unexpanded{moretexcs={[6]#1}}}% + {\expandonce\cnltx@listings@style,\unexpanded{morekeywords={[6]#1}}}% \edef\cnltx@listings@style{% - \expandonce\cnltx@listings@style,\unexpanded{moretexcs={[6]#1}}% + \expandonce\cnltx@listings@style,\unexpanded{morekeywords={[6]#1}}% }% } @@ -512,7 +567,7 @@ \cnltx@get@page@list{#1} \booltrue{cnltx@pagelist} , runs/.code = \setcounter{cnltx@runs}{#1} , - program/.code = \def\cnltx@compilation@method{#1} , + program/.code = \def\cnltx@compilation@methods{#1} , file-ext/.code = \def\cnltx@example@fileext{#1} , exe-with/.code = \def\cnltx@compilation@options{#1} , graphics/.code = \def\cnltx@image@options{#1} , @@ -596,10 +651,17 @@ } \newcommand*\cnltx@exe{\immediate\write18} -\newcommand*\cnltx@program@pdflatex{pdflatex} -\newcommand*\cnltx@program@lualatex{lualatex} -\newcommand*\cnltx@program@xelatex {xelatex} -\newcommand*\cnltx@program@arara {arara} +\newrobustcmd*\cnltx@add@program[1]{% + \expandafter\newcommand + \expandafter*\csname cnltx@program@#1\endcsname{#1}% +} +\cnltx@add@program{pdflatex} +\cnltx@add@program{lualatex} +\cnltx@add@program{xelatex} +\cnltx@add@program{arara} +\cnltx@add@program{biber} +\cnltx@add@program{bibtex} + \newcommand*\cnltx@compile[3]{% \ifcsdef{cnltx@program@#1} {% @@ -613,9 +675,16 @@ } {\cnltx@example@error{Unknown compilation method `#1'}}% } -\newcommand*\cnltx@compilation@method{pdflatex} +\newcommand*\cnltx@compilation@methods{pdflatex} \newcommand*\cnltx@compilation@options{} +\newrobustcmd*\cnltx@compilation@process[2]{ + \cnltx@expandargs(oo)\cnltx@compile + {#2} + {\cnltx@compilation@options} + {#1}% +} + \newrobustcmd*\cnltx@get@pdfpages[1]{% \begingroup \ifxetex @@ -657,8 +726,7 @@ {% \cnltx@expandargs(x)\lstset{ \ifboolexpe{ bool {cnltx@sidebyside} and not bool {cnltx@codeonly} } - {linewidth=\cnltx@sidebysidewidth,}{}% - moretexcs=[3], moretexcs=[5], + {linewidth=\cnltx@sidebysidewidth,}{}% \expandonce\cnltx@local@listings@options }% } @@ -668,8 +736,6 @@ \ifboolexpe{ bool {cnltx@sidebyside} and not bool {cnltx@codeonly} } {linewidth=\cnltx@sidebysidewidth,}{}% \expandonce\cnltx@local@listings@options - % no idea why this is necessary: - % \ifcsdef{lst@gtexcs3}{}{,moretexcs=[3]}% }% }% \ifbool{cnltx@local@frame@overwrite} @@ -819,12 +885,11 @@ {% Compiling example `#1.tex' \arabic{cnltx@runs} time\ifnum\value{cnltx@runs}>1s\fi\space with - \cnltx@compilation@method + \cnltx@compilation@methods }% - \cnltx@expandargs(oo)\cnltx@compile - {\cnltx@compilation@method} - {\cnltx@compilation@options} - {#1.tex}% + \cnltx@expandargs(no)\forcsvlist + {\cnltx@compilation@process{#1}} + {\cnltx@compilation@methods}% } {% \cnltx@example@warning @@ -926,6 +991,7 @@ \vskip\cnltx@after@skip }% } + \newrobustcmd\newsourcecodeenv[2][]{% \cnltx@new@sourcecode@env{#1}{#2}% } @@ -950,6 +1016,12 @@ \newsourcecodeenv[side-by-side]{sidebyside} \newsourcecodeenv[code-only]{sourcecode} +\newsourcecodeenv[ + code-only, + sourcecode-options={style=bash}, + pre-code=\def\cnltx@prompt{\textasciitilde\space\$\space} +]{bash} + \newinputsourcefilecmd\inputexample \newinputsourcefilecmd[side-by-side]\inputsidebyside \newinputsourcefilecmd[code-only]\inputsourcecode @@ -958,7 +1030,6 @@ \lstinputlisting[style=cnltx,#1]{#2}% } - % -------------------------------------------------------------------------- % packages and classes: \newcommand*\packageformat{\sffamily} @@ -995,50 +1066,59 @@ % -------------------------------------------------------------------------- HISTORY: -2013/09/08 v0.1 - first working version -2013/09/10 v0.2 - added \keyis - - lot's of improvements on the source code example - environments - - disable indexing commands in PDF strings - - added hooks to the source example environments - - added possibility for internationalization - - new macro \verbcode - - added optional argument to \newarg - - new macros \Marg, \Oarg, \Darg - - option for formatting the \default command -2013/09/12 v0.3 - added \module - - added \newsourcecodeenv and \newinputsourcefilecmd - - added \inputexample, \inputsidebyside and \inputsourcecode - - renamed `example*' into `sidebyside' -2013/09/15 v0.4 - new listings style `cnltx-bibtex' -2013/09/20 v0.5 - new command \implementation - - fixed wrong indexing behaviour: keywords in the silent lists - are now correctly indexed if added with `add-cmds' or - `add-envs' -2013/09/30 v0.7 - added listings style `cnltx-makeindex' -2013/10/04 v0.7a - new command \cnltx@treat@lst@index - - changed \envidx in listings into \indexenv - - added \bnd for package bundles -2013/11/22 v0.9 - new option `compile' that allows to compile source code - examples (which need to be complete, of course) with - pdflatex and include the documents afterwards - - new options `max-pages' that determines the maximum number - of pages before a line break if documents are included with - `compile' - - new option `graphics' - - new option `runs' that specifies the number of compilation - runs of the included example - - new options `program' and `exe-with' - - new option `float', `float-pos' and `caption' -2014/01/05 v0.10 - sometimes there is a spurious `undefined control sequence - \lst@gtexcs3' error: added hack to fix this => find out - where this comes from! - - new option `add-frame' for `compile'd examples - - new command \parg for an optional + argument - - new option `outside' for non-`compiled' examples - - new option `float-env' -2014/03/11 v0.11 - \cnltx@load@modules -2014/04/09 v0.12 - improvements on the sidebyside examples +2013/09/08 v0.1 - first working version +2013/09/10 v0.2 - added \keyis + - lot's of improvements on the source code example + environments + - disable indexing commands in PDF strings + - added hooks to the source example environments + - added possibility for internationalization + - new macro \verbcode + - added optional argument to \newarg + - new macros \Marg, \Oarg, \Darg + - option for formatting the \default command +2013/09/12 v0.3 - added \module + - added \newsourcecodeenv and \newinputsourcefilecmd + - added \inputexample, \inputsidebyside and \inputsourcecode + - renamed `example*' into `sidebyside' +2013/09/15 v0.4 - new listings style `cnltx-bibtex' +2013/09/20 v0.5 - new command \implementation + - fixed wrong indexing behaviour: keywords in the silent + lists are now correctly indexed if added with `add-cmds' + or `add-envs' +2013/09/30 v0.7 - added listings style `cnltx-makeindex' +2013/10/04 v0.7a - new command \cnltx@treat@lst@index + - changed \envidx in listings into \indexenv + - added \bnd for package bundles +2013/11/22 v0.9 - new option `compile' that allows to compile source code + examples (which need to be complete, of course) with + pdflatex and include the documents afterwards + - new options `max-pages' that determines the maximum number + of pages before a line break if documents are included + with `compile' + - new option `graphics' + - new option `runs' that specifies the number of compilation + runs of the included example + - new options `program' and `exe-with' + - new option `float', `float-pos' and `caption' +2014/01/05 v0.10 - sometimes there is a spurious `undefined control sequence + \lst@gtexcs3' error: added hack to fix this => find out + where this comes from! + - new option `add-frame' for `compile'd examples + - new command \parg for an optional + argument + - new option `outside' for non-`compiled' examples + - new option `float-env' +2014/03/11 v0.11 - \cnltx@load@modules +2014/04/09 v0.12 - improvements on the sidebyside examples +2015/08/29 v0.13a - enable \choices list to stretch +2016/03/16 v0.13b - `program' may now be a csv list of programs to be + executed +2017/02/04 v0.14 - exchange literate={`}{\`{}}{1}{'}{\textquotesingle}{1} for + listings' upquote option + - new sourcecode environment `bash' +2019/11/01 v0.15 - fix `undefined control sequence \lst@gtexcs3' error + - fix `undefined control sequence \lst@gkeyword3' error + - fix `undefined control sequence \lst@gkeyword3' error TODO: |