diff options
Diffstat (limited to 'macros/latex/contrib/democodetools/latex/democodelisting.sty')
-rw-r--r-- | macros/latex/contrib/democodetools/latex/democodelisting.sty | 1044 |
1 files changed, 522 insertions, 522 deletions
diff --git a/macros/latex/contrib/democodetools/latex/democodelisting.sty b/macros/latex/contrib/democodetools/latex/democodelisting.sty index 1041b6f249..21e74cac82 100644 --- a/macros/latex/contrib/democodetools/latex/democodelisting.sty +++ b/macros/latex/contrib/democodetools/latex/democodelisting.sty @@ -1,522 +1,522 @@ -%%%==============================================================================
-%% Copyright 2022 by Alceu Frigeri
-%%
-%%
-%% This work may be distributed and/or modified under the
-%% conditions of the LaTeX Project Public License, either 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.3 or later is part of all distributions of LaTeX
-%% version 2005/12/01 or later.
-%%
-%% This work has the LPPL maintenance status “maintained”.
-%%
-%% The Current Maintainer of this work is Alceu Frigeri
-%%
-%% This is version 1.0beta (2022/09/01)
-%%
-%%
-%% This work consists of the files
-%%
-%% democodelisting.sty set of macros to typeset and demonstrate LaTeX code
-%% democodetools.sty set of macros to document LaTeX packages
-%%
-%% README.md quick introduction
-%%
-%% democodetools.tex LaTeX documentation
-%% democodetools.pdf documentation in PDF form
-%%
-%%%==============================================================================
-\NeedsTeXFormat{LaTeX2e}[2022/06/01]
-\def\tc@tmp@packname{democodelisting}
-\def\tc@tmp@altpackname{democodelisting}
-\def\tc@tmp@packdesc{Demo Code Listing}
-\def\tc@tmp@packdate{2022/09/01}
-\def\tc@tmp@packversion{1.0beta}
-\let\@exp\expandafter
-\@exp\edef\csname\tc@tmp@altpackname version\endcsname{\tc@tmp@packversion}
-\@exp\@exp\@exp\ProvidesPackage\@exp\@exp\@exp{\@exp\tc@tmp@packname\@exp}\@exp[\tc@tmp@packdate\space v\tc@tmp@packversion\space\tc@tmp@packdesc]
-
-\RequirePackage{listings}
-\RequirePackage{scontents}
-
-\newlength{\dc@demo@parindent}
-\newlength{\dc@org@parindent}
-\setlength\dc@org@parindent{\parindent}
-\setlength\parindent{0pt}
-
-
-\colorlet{dc@lightcyan}{white!97!cyan}
-\colorlet{dc@lightgray}{white!97!black}
-\definecolor{dc@grayblack}{rgb}{0.8,0.8,0.8}
-
-\colorlet{dc@darkgreen}{green!45!black!100}
-\colorlet{dc@darkteal}{teal!45!black!100}
-\colorlet{dc@darkblue}{blue!40!black!100}
-\colorlet{dc@darkred}{red!45!black!100}
-
-\colorlet{dc@blueishblack}{blue!75!black!100}
-\colorlet{dc@reddishblack}{red!60!black!100}
-\colorlet{dc@greenishblack}{green!45!black!100}
-
-\def\dc@lstbckgndcolordefault{dc@lightgray}%
-\def\dc@lststringcolordefault{dc@darkteal}
-\def\dc@lstcommentcolordefault{dc@darkgreen}
-\def\dc@lsttexcscolordefault{dc@darkblue}
-\def\dc@lstkeywdcolordefault{dc@darkblue}
-
-\def\dc@lsttexcsBcolordefault{dc@blueishblack}
-\def\dc@lstkeywdBcolordefault{dc@greenishblack}
-\def\dc@lstemphcolordefault{dc@reddishblack}
-
-\colorlet{dc@lstnumbercolordefault}{white!50!black!100}
-
-\def\dc@lstrulecolordefault{gray}
-\def\dc@lstnumbercolordefault{gray}
-
-\DeclareKeys[dclisting]{
- settexcs.usage = general,
- settexcs.code = {\ifblank{#1}{\def\dc@lsttexcs{}}{\def\dc@lsttexcs{#1}}},
- texcs.usage = general,
- texcs.code = {\ifblank{#1}{}{\edef\dc@lsttexcs{\dc@lsttexcs,#1}}},
- texcsstyle.usage = general,
- texcsstyle.code = {\ifblank{#1}{\def\dc@lsttexcsstyle{\bfseries\color{\dc@lsttexcscolordefault}}}{\def\dc@lsttexcsstyle{#1}}},
-
- settexcs2.usage = general,
- settexcs2.code = {\ifblank{#1}{\def\dc@lsttexcsB{}}{\def\dc@lsttexcsB{#1}}},
- texcs2.usage = general,
- texcs2.code = {\ifblank{#1}{}{\edef\dc@lsttexcsB{\dc@lsttexcsB,#1}}},
- texcs2style.usage = general,
- texcs2style.code = {\ifblank{#1}{\def\dc@lsttexcsBstyle{\bfseries\color{\dc@lsttexcsBcolordefault}}}{\def\dc@lsttexcsBstyle{#1}}},
-
- settexcs3.usage = general,
- settexcs3.code = {\ifblank{#1}{\def\dc@lsttexcsC{}}{\def\dc@lsttexcsC{#1}}},
- texcs3.usage = general,
- texcs3.code = {\ifblank{#1}{}{\edef\dc@lsttexcsC{\dc@lsttexcsC,#1}}},
- texcs3style.usage = general,
- texcs3style.code = {\ifblank{#1}{\def\dc@lsttexcsCstyle{\bfseries\color{\dc@lsttexcsBcolordefault}}}{\def\dc@lsttexcsCstyle{#1}}},
-
- setkeywd.usage = general,
- setkeywd.code = {\ifblank{#1}{\def\dc@lstkeywd{}}{\def\dc@lstkeywd{#1}}},
- keywd.usage = general,
- keywd.code = {\ifblank{#1}{}{\edef\dc@lstkeywd{\dc@lstkeywd,#1}}},
- keywdstyle.usage = general,
- keywdstyle.code = {\ifblank{#1}{\def\dc@lstkeywdstyle{\bfseries\color{\dc@lstkeywdcolordefault}}}{\def\dc@lstkeywdstyle{#1}}},
-
- setkeywd2.usage = general,
- setkeywd2.code = {\ifblank{#1}{\def\dc@lstkeywdB{}}{\def\dc@lstkeywdB{#1}}},
- keywd2.usage = general,
- keywd2.code = {\ifblank{#1}{}{\edef\dc@lstkeywdB{\dc@lstkeywdB,#1}}},
- keywd2style.usage = general,
- keywd2style.code = {\ifblank{#1}{\def\dc@lstkeywdBstyle{\bfseries\color{\dc@lstkeywdBcolordefault}}}{\def\dc@lstkeywdBstyle{#1}}},
-
- setkeywd3.usage = general,
- setkeywd3.code = {\ifblank{#1}{\def\dc@lstkeywdC{}}{\def\dc@lstkeywdC{#1}}},
- keywd3.usage = general,
- keywd3.code = {\ifblank{#1}{}{\edef\dc@lstkeywdC{\dc@lstkeywdC,#1}}},
- keywd3style.usage = general,
- keywd3style.code = {\ifblank{#1}{\def\dc@lstkeywdCstyle{\bfseries\color{\dc@lstkeywdBcolordefault}}}{\def\dc@lstkeywdCstyle{#1}}},
-
- setemph.usage = general,
- setemph.code = {\ifblank{#1}{\def\dc@lstemph{}}{\def\dc@lstemph{#1}}},
- emph.usage = general,
- emph.code = {\ifblank{#1}{}{\edef\dc@lstemph{\dc@lstemph,#1}}},
- emphstyle.usage = general,
- emphstyle.code = {\ifblank{#1}{\def\dc@lstemphstyle{\bfseries\color{\dc@lstemphcolordefault}}}{\def\dc@lstemphstyle{#1}}},
-
- setemph2.usage = general,
- setemph2.code = {\ifblank{#1}{\def\dc@lstemphB{}}{\def\dc@lstemphB{#1}}},
- emph2.usage = general,
- emph2.code = {\ifblank{#1}{}{\edef\dc@lstemphB{\dc@lstemphB,#1}}},
- emph2style.usage = general,
- emph2style.code = {\ifblank{#1}{\def\dc@lstemphBstyle{\bfseries\color{\dc@lstemphcolordefault}}}{\def\dc@lstemphBstyle{#1}}},
-
- setemph3.usage = general,
- setemph3.code = {\ifblank{#1}{\def\dc@lstemphC{}}{\def\dc@lstemphC{#1}}},
- emph3.usage = general,
- emph3.code = {\ifblank{#1}{}{\edef\dc@lstemphC{\dc@lstemphC,#1}}},
- emph3style.usage = general,
- emph3style.code = {\ifblank{#1}{\def\dc@lstemphCstyle{\bfseries\color{\dc@lstemphcolordefault}}}{\def\dc@lstemphCstyle{#1}}},
-
- stringstyle.usage = general,
- stringstyle.code = {\ifblank{#1}{\def\dc@lststringstyle{\color{\dc@lststringcolordefault}}}{\def\dc@lststringstyle{#1}}},
-
- commentstyle.usage = general,
- commentstyle.code = {\ifblank{#1}{\def\dc@lstcommentstyle{\color{\dc@lstcommentcolordefault}}}{\def\dc@lstcommentstyle{#1}}},
-
- bckgndcolor.usage = general,
- bckgndcolor.code = {\ifblank{#1}{\def\dc@lstbckgndcolor{\color{\dc@lstbckgndcolordefault}}}{\def\dc@lstbckgndcolor{#1}}},
-
- rulecolor.usage = general,
- rulecolor.code = {\ifblank{#1}{\def\dc@lstrulecolor{\color{\dc@lstrulecolordefault}}}{\def\dc@lstrulecolor{#1}}},
-
- numbers.usage = general,
- numbers.code = {\ifblank{#1}{\def\dc@lstnumbers{none}}{\def\dc@lstnumbers{#1}}},
-
- numberstyle.usage = general,
- numberstyle.code = {\ifblank{#1}{\def\dc@lstnumberstyle{\tiny\color{\dc@lstnumbercolordefault}}}{\def\dc@lstnumberstyle{#1}}},
-
- parindent.usage = general,
- parindent.code = {\setlength\dc@demo@parindent{\parindent}\setdcpar{#1}},
-
- default.usage = general,
- default.code = {\dc@lstkeysdefault},
-}
-\NewDocumentCommand{\setdclisting}{m}{\SetKeys[dclisting]{#1}}
-\NewDocumentCommand{\dc@lstkeysdefault}{}{%
- \setdclisting{%
- settexcs,texcsstyle,settexcs2,texcs2style,settexcs3,texcs3style,%
- setkeywd,keywdstyle,setkeywd2,keywd2style,setkeywd3,keywd3style,%
- setemph,emphstyle,setemph2,emph2style,setemph3,emph3style,%
- stringstyle,commentstyle,bckgndcolor,rulecolor,%
- numbers,numberstyle,%
- }%
-}
-\setdclisting{default}
-
-\DeclareKeys[dcpar]{
- org.usage = general,
- org.code = {\setlength\dc@demo@parindent\dc@org@parindent},
- default.usage = general,
- default.code = {\setlength\dc@demo@parindent\parindent},
-}
-\DeclareUnknownKeyHandler[dcpar]{\ifblank{#1}{\setlength\dc@demo@parindent\dc@org@parindent}{\setlength\dc@demo@parindent{#1}}}
-
-\NewDocumentCommand{\setdcpar}{m}{\SetKeys[dcpar]{#1}}
-
-\DeclareKeys[dclisting]{
- codeprefix.usage = general,
- codeprefix.code = {\ifblank{#1}{\def\dc@codeprefix{\LaTeX~Code:}}{\def\dc@codeprefix{#1}}},
-
- resultprefix.usage = general,
- resultprefix.code = {\ifblank{#1}{\def\dc@resultprefix{\LaTeX~Result:}}{\def\dc@resultprefix{#1}}},
-
- defaulttools.usage = general,
- defaulttools.code = {\SetKeys[dclisting]{codeprefix,resultprefix}} ,
-}
-%\DeclareUnknownKeyHandler[dclisting]{\setdclisting{#1={#2}}}
-
-%\NewDocumentCommand{\setdctools}{m}{\SetKeys[dctools]{#1}}
-\SetKeys[dclisting]{defaulttools}
-
-
-
-%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%
-%%%
-%%% From doctools.dtx file
-%%% lstlistings 'definitions'
-%%%
-%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%
-
-%%% listings
-%
-\lstdefinestyle{lstStyleDefault}{
-%%% appearance
- ,basicstyle=\small\ttfamily % Standardschrift
-%%% Space and placement
- ,floatplacement=tbp % is used as float place specifier
- ,aboveskip=\medskipamount % define the space above and
- ,belowskip=\medskipamount % below displayed listings.
- ,lineskip=0pt % specifies additional space between lines in listings.
- ,boxpos=c % c,b,t
-%%% The printed range
- ,showlines=false % prints empty lines at the end of listings
-%%% characters
- ,extendedchars=true % allows or prohibits extended characters
- % in listings, that means (national)
- % characters of codes 128-255.
- ,upquote=true % determines printing of quotes
- ,tabsize=2, % chars of tab
- ,showtabs=false % do not show tabs
- ,showspaces=false % do not show spaces
- ,showstringspaces=false % do not show blank spaces in string
-%%% Line numbers
- ,numbers=none % left, right, none
-%%% Captions
- ,numberbychapter=true %
- ,captionpos=b % t,b
- ,abovecaptionskip=\smallskipamount % the vertical space respectively above
- ,belowcaptionskip=\smallskipamount % or below each caption
-%%% Margins and line shape
- ,linewidth=\linewidth % defines the base line width for listings.
- ,xleftmargin=0pt % extra margins
- ,xrightmargin=0pt %
- ,resetmargins=false % indention from list environments like enumerate
- % or itemize is reset, i.e. not used.
- ,breaklines=true % line breaking of long lines.
- ,breakatwhitespace=false % allows line breaks only at white space.
- ,breakindent=0pt % is the indention of the second, third, ...
- % line of broken lines.
- ,breakautoindent=true % apply intendation
- ,columns=flexible %
- ,keepspaces=true %
-}
-
-
-\lstdefinestyle{lstDocStyleBase}{
-%%% base style
-%
- ,style=lstStyleDefault
-%%% appearance
- ,commentstyle=\slshape
-%%% Line numbers
- ,numbers=left % left, right, none
- ,stepnumber=1 % seperation between numbers
- ,numberfirstline=false % number first line always
- ,numberstyle={\dc@lstnumberstyle} % style of numbers
- ,numbersep=5pt % distance to text
- ,numberblanklines=true %
-%%% language
- ,language = [LaTeX]TeX
-%%% commands
- % LaTeX programming
- ,moretexcs={setlength,usepackage,newcommand,renewcommand,providecommand,RequirePackage,SelectInputMappings,ifpdftex,ifpdfoutput,AtBeginEnvironment,ProvidesPackage},
- % other commands
- ,moretexcs={maketitle,text,includegraphics,chapter,section,subsection,
- subsubsection,paragraph,textmu,enquote,blockquote,ding,mathds,ifcsdef,Bra,Ket,Braket,subcaption,lettrine,mdfsetup,captionof,listoffigures,listoftables,tableofcontents,appendix}
- % tables
- ,moretexcs={newcolumntype,rowfont,taburowcolors,rowcolor,rowcolors,bottomrule,
- toprule,midrule,}
- % hyperref
- ,moretexcs={hypersetup}
- % glossaries
- ,moretexcs={gls,printglossary,glsadd,newglossaryentry,newacronym}
- % Koma
- ,moretexcs={mainmatter,frontmatter,geometry,KOMAoptions,setkomafont,addtokomafont}
- % SI, unit
- ,moretexcs={si,SI,sisetup,unit,unitfrac,micro}
- % biblatex package
- ,moretexcs={newblock,ExecuteBibliographyOptions,addbibresource}
- % math packages
- ,moretexcs={operatorname,frac,sfrac,dfrac,DeclareMathOperator,mathcal,underset}
- % demo package
- ,moretexcs={democodefile,package,cs,command,env,DemoError,PrintDemo}
- % tablestyles
- ,moretexcs={theadstart,tbody,tsubheadstart,tsubhead,tend}
- % code section package
- ,moretexcs={DefineCodeSection,SetCodeSection,BeginCodeSection,
- EndCodeSection}
- % template tools package
- ,moretexcs={IfDefined,IfUndefined,IfElseDefined,IfElseUndefined,IfMultDefined,IfNotDraft,IfNotDraftElse,IfDraft,IfPackageLoaded,IfElsePackageLoaded,IfPackageNotLoaded,IfPackagesLoaded,IfPackagesNotLoaded,ExecuteAfterPackage,ExecuteBeforePackage,IfTikzLibraryLoaded,IfColumntypeDefined,IfColumntypesDefined,IfColorDefined,IfColorsDefined,IfMathVersionDefined,SetTemplateDefinition,UseDefinition,IfFileExists,iflanguage}
- % tablestyles
- ,moretexcs={setuptablefontsize,tablefontsize,setuptablestyle,tablestyle, setuptablecolor,tablecolor,disablealternatecolors, tablealtcolored,tbegin,tbody,tend,thead, theadstart,tsubheadstart,tsubhead,theadrow,tsubheadrow,resettablestyle,theadend,tsubheadend,tableitemize,PreserveBackslash}
- % todonotes
- ,moretexcs={todo,missingfigure}
- % listings
- ,moretexcs={lstloadlanguages,lstdefinestyle,lstset}
- % index
- ,moretexcs={indexsetup}
- % glossaries
- ,moretexcs={newglossarystyle,glossarystyle,deftranslation,newglossary}
- % tikz
- ,moretexcs={usetikzlibrary}
- % color
- ,moretexcs={definecolor,colorlet}
- % caption
- ,moretexcs={captionsetup,DeclareCaptionStyle}
- % floatrow
- ,moretexcs={floatsetup}
- % doc.sty
- ,moretexcs={EnableCrossrefs,DisableCrossrefs,PageIndex,CodelineIndex,CodelineNumbered}
- % refereces
- ,moretexcs={cref,Cref,vref,eqnref,figref,tabref,secref,chapref}
-}
-
-%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%
-%%%
-%%% From doctools.dtx file
-%%% lstlistings 'definitions'
-%%%
-%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%
-
-
-
-\lstloadlanguages{[LaTeX]TeX}
-\lstdefinestyle{codestyle}{
-%%% base style
- style=lstDocStyleBase,
- language=[LaTeX]{TeX},
- numbers=none,%{\dc@lstnumbers},%
- %%% colors
- rulecolor={\dc@lstrulecolor},
- backgroundcolor={\dc@lstbckgndcolor},%
- stringstyle={\dc@lststringstyle},
- commentstyle={\dc@lstcommentstyle},
- framerule=0pt,%0.4pt,
- nolol=true,
- frame=none,
- aboveskip=-2ex,
- belowskip=-2ex,
- basicstyle=\footnotesize\ttfamily , % Standardschrift
- rulesep = 0pt,
- breaklines=true,
- breakindent=3em,
- moretexcs={\dc@lsttexcs},
- moretexcs=[2]{\dc@lsttexcsB},
- moretexcs=[3]{\dc@lsttexcsC},
- texcsstyle=*{\dc@lsttexcsstyle},
- texcsstyle=*[2]{\dc@lsttexcsBstyle},
- texcsstyle=*[3]{\dc@lsttexcsCstyle},
- morekeywords={\dc@lstkeywd},
- morekeywords=[2]{\dc@lstkeywdB},
- morekeywords=[3]{\dc@lstkeywdC},
- keywordstyle={\dc@lstkeywdstyle},
- keywordstyle=[2]{\dc@lstkeywdBstyle},
- keywordstyle=[3]{\dc@lstkeywdCstyle},
- emph={\dc@lstemph},
- emph=[2]{\dc@lstemphB},
- emph=[3]{\dc@lstemphC},
- emphstyle={\dc@lstemphstyle},
- emphstyle=[2]{\dc@lstemphBstyle},
- emphstyle=[3]{\dc@lstemphCstyle},
-}
-\lstset{style=codestyle}
-
-%%%
-%%% Using scontents package !!!!
-%%%
-\ExplSyntaxOn
-\keys_define:nn { scontents / scontents}
- {
- st.meta:nn = { scontents } { store-env = #1 },
- st.value_required:n = true
- }
-\ExplSyntaxOff
-
-\newenvsc{stcode}
-\let\verbatimsc\@undefined
-\let\verbatimsc@\@undefined
-\let\endverbatimsc\@undefined
-\lstnewenvironment{verbatimsc}{\lstset{style=codestyle}}{}
-
-
-\NewDocumentEnvironment{verbsc}{m}{%
- \let\verbatimsc\@undefined
- \let\verbatimsc@\@undefined
- \let\endverbatimsc\@undefined
- \setdclisting{#1}
- \edef\dc@tmp{style=codestyle,moretexcs={\dc@lsttexcs},moretexcs=[2]{\dc@lsttexcsB},moretexcs=[3]{\dc@lsttexcsC},%
- morekeywords={\dc@lstkeywd},morekeywords=[2]{\dc@lstkeywdB},morekeywords=[3]{\dc@lstkeywdC},%
- emph={\dc@lstemph},emph=[2]{\dc@lstemphB},emph=[3]{\dc@lstemphC},%
- numbers={\dc@lstnumbers}}
- \lstnewenvironment{verbatimsc}{\expandafter\lstset\expandafter{\dc@tmp}}{}
-}{%
-}
-
-\NewDocumentCommand{\DisplayCodeB}{O{}m}{%
- {%
- \begin{verbsc}{#1}%
- \begin{tabular}{J{.98\textwidth}}\dc@codeprefix \\
- \typestored{#2}%
- \end{tabular}%
- \end{verbsc}%
- }%
-}
-
-\NewDocumentCommand{\DemoCodeB}{O{}m}{{%
- \setlength\parindent\dc@org@parindent
- \begin{verbsc}{#1}%
- \begin{tabular}{J{.98\textwidth}}%
- \dc@codeprefix \\%
- \typestored{#2}\\%
- \end{tabular}%
-
- \begin{tabular}{J{.98\textwidth}}%
- \dc@resultprefix \\\hline\\[-1ex]%
- \getstored{#2}\\\hline%
- \end{tabular}%
- \end{verbsc}%
-}}
-
-\NewDocumentCommand{\TabbedDemoCodeB}{O{}m}{{%
- \setlength\parindent\dc@org@parindent
- \begin{verbsc}{#1}%
- \arrayrulecolor{gray}
- \begin{tabular}{J{.49\textwidth}@{}J{.49\textwidth}}%
- \dc@codeprefix & \dc@resultprefix\\\hline\\[-1ex]%
- \typestored{#2} & \getstored{#2}\\\hline%
- \end{tabular}%
- \end{verbsc}%
-}}
-
-
-\NewDocumentCommand{\DisplayCode}{O{}m}{{%
- \begin{verbsc}{#1}%
- \vspace*{0.5ex}
- \begin{minipage}{1\textwidth}\dc@codeprefix \\
- \typestored{#2}%
- \end{minipage}%
- \\[1.5ex]%
- \end{verbsc}%
-}}
-
-\NewDocumentCommand{\DemoCode}{O{}mO{1ex}}{{%
- \begin{verbsc}{#1}%
- \vspace*{1ex}
- \begin{minipage}{1\textwidth}\dc@codeprefix \\
- \typestored{#2}%
- \end{minipage}%
- \\[3ex]
- \begin{minipage}{1\textwidth}%
- \dc@resultprefix \\[-1.5ex]%
- \rule{\textwidth}{0.2pt}\vspace*{0.75ex}%
- \setlength\parindent\dc@demo@parindent%
-
- \getstored{#2}%
- \end{minipage}%
- \\[#3]%
- \rule{1\textwidth}{0.2pt}%\vspace*{0.25ex}
- \end{verbsc}%
-}}
-
-\NewDocumentCommand{\TabbedDemoCode}{O{}mO{1ex}}{{%
- \begin{verbsc}{#1}%
- \begin{minipage}{.5\textwidth}%
- \dc@codeprefix%
- \end{minipage}%
- \begin{minipage}{.5\textwidth}%
- \dc@resultprefix%
- \end{minipage}\\[-1.5ex]%
- \rule{\textwidth}{0.2pt}\vspace*{1ex}%
-
- \begin{minipage}{.5\textwidth}\vspace*{2ex}%
- \typestored{#2}\vspace*{1.5ex}%
- \end{minipage}%
- \begin{minipage}{.5\textwidth}%
- \setlength\parindent\dc@demo@parindent%
- \getstored{#2}%
- \end{minipage}%
- \\[#3]%
- \rule{1\textwidth}{0.2pt}%\vspace*{0.5ex}
- \end{verbsc}%
-}}
-%%%
-%%% Using scontents package !!!!
-%%%
-
-
-%%%
-%%% from https://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings#Encoding_issue
-\lstset{literate=
- {á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1
- {Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1
- {à}{{\`a}}1 {è}{{\`e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1
- {À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1
- {ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1
- {Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1
- {â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1
- {Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1
- {ã}{{\~{a}}}1 {õ}{{\~{o}}}1
- {Ã}{{\~{A}}}1 {Õ}{{\~{O}}}1
- {ý}{{\'{y}}}1 {Ý}{{\'{Y}}}1 {ÿ}{{\"{y}}}1 {Ÿ}{{\"{Y}}}1
- {œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1
- {ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1
- {€}{{\EUR}}1 {£}{{\pounds}}1
-}
-
-\endinput
+%%%============================================================================== +%% Copyright 2022 by Alceu Frigeri +%% +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either 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.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status “maintained”. +%% +%% The Current Maintainer of this work is Alceu Frigeri +%% +%% This is version 1.0beta (2022/09/01) +%% +%% +%% This work consists of the files +%% +%% democodelisting.sty set of macros to typeset and demonstrate LaTeX code +%% democodetools.sty set of macros to document LaTeX packages +%% +%% README.md quick introduction +%% +%% democodetools.tex LaTeX documentation +%% democodetools.pdf documentation in PDF form +%% +%%%============================================================================== +\NeedsTeXFormat{LaTeX2e}[2022/06/01] +\def\tc@tmp@packname{democodelisting} +\def\tc@tmp@altpackname{democodelisting} +\def\tc@tmp@packdesc{Demo Code Listing} +\def\tc@tmp@packdate{2022/09/01} +\def\tc@tmp@packversion{1.0beta} +\let\@exp\expandafter +\@exp\edef\csname\tc@tmp@altpackname version\endcsname{\tc@tmp@packversion} +\@exp\@exp\@exp\ProvidesPackage\@exp\@exp\@exp{\@exp\tc@tmp@packname\@exp}\@exp[\tc@tmp@packdate\space v\tc@tmp@packversion\space\tc@tmp@packdesc] + +\RequirePackage{listings} +\RequirePackage{scontents} + +\newlength{\dc@demo@parindent} +\newlength{\dc@org@parindent} +\setlength\dc@org@parindent{\parindent} +\setlength\parindent{0pt} + + +\colorlet{dc@lightcyan}{white!97!cyan} +\colorlet{dc@lightgray}{white!97!black} +\definecolor{dc@grayblack}{rgb}{0.8,0.8,0.8} + +\colorlet{dc@darkgreen}{green!45!black!100} +\colorlet{dc@darkteal}{teal!45!black!100} +\colorlet{dc@darkblue}{blue!40!black!100} +\colorlet{dc@darkred}{red!45!black!100} + +\colorlet{dc@blueishblack}{blue!75!black!100} +\colorlet{dc@reddishblack}{red!60!black!100} +\colorlet{dc@greenishblack}{green!45!black!100} + +\def\dc@lstbckgndcolordefault{dc@lightgray}% +\def\dc@lststringcolordefault{dc@darkteal} +\def\dc@lstcommentcolordefault{dc@darkgreen} +\def\dc@lsttexcscolordefault{dc@darkblue} +\def\dc@lstkeywdcolordefault{dc@darkblue} + +\def\dc@lsttexcsBcolordefault{dc@blueishblack} +\def\dc@lstkeywdBcolordefault{dc@greenishblack} +\def\dc@lstemphcolordefault{dc@reddishblack} + +\colorlet{dc@lstnumbercolordefault}{white!50!black!100} + +\def\dc@lstrulecolordefault{gray} +\def\dc@lstnumbercolordefault{gray} + +\DeclareKeys[dclisting]{ + settexcs.usage = general, + settexcs.code = {\ifblank{#1}{\def\dc@lsttexcs{}}{\def\dc@lsttexcs{#1}}}, + texcs.usage = general, + texcs.code = {\ifblank{#1}{}{\edef\dc@lsttexcs{\dc@lsttexcs,#1}}}, + texcsstyle.usage = general, + texcsstyle.code = {\ifblank{#1}{\def\dc@lsttexcsstyle{\bfseries\color{\dc@lsttexcscolordefault}}}{\def\dc@lsttexcsstyle{#1}}}, + + settexcs2.usage = general, + settexcs2.code = {\ifblank{#1}{\def\dc@lsttexcsB{}}{\def\dc@lsttexcsB{#1}}}, + texcs2.usage = general, + texcs2.code = {\ifblank{#1}{}{\edef\dc@lsttexcsB{\dc@lsttexcsB,#1}}}, + texcs2style.usage = general, + texcs2style.code = {\ifblank{#1}{\def\dc@lsttexcsBstyle{\bfseries\color{\dc@lsttexcsBcolordefault}}}{\def\dc@lsttexcsBstyle{#1}}}, + + settexcs3.usage = general, + settexcs3.code = {\ifblank{#1}{\def\dc@lsttexcsC{}}{\def\dc@lsttexcsC{#1}}}, + texcs3.usage = general, + texcs3.code = {\ifblank{#1}{}{\edef\dc@lsttexcsC{\dc@lsttexcsC,#1}}}, + texcs3style.usage = general, + texcs3style.code = {\ifblank{#1}{\def\dc@lsttexcsCstyle{\bfseries\color{\dc@lsttexcsBcolordefault}}}{\def\dc@lsttexcsCstyle{#1}}}, + + setkeywd.usage = general, + setkeywd.code = {\ifblank{#1}{\def\dc@lstkeywd{}}{\def\dc@lstkeywd{#1}}}, + keywd.usage = general, + keywd.code = {\ifblank{#1}{}{\edef\dc@lstkeywd{\dc@lstkeywd,#1}}}, + keywdstyle.usage = general, + keywdstyle.code = {\ifblank{#1}{\def\dc@lstkeywdstyle{\bfseries\color{\dc@lstkeywdcolordefault}}}{\def\dc@lstkeywdstyle{#1}}}, + + setkeywd2.usage = general, + setkeywd2.code = {\ifblank{#1}{\def\dc@lstkeywdB{}}{\def\dc@lstkeywdB{#1}}}, + keywd2.usage = general, + keywd2.code = {\ifblank{#1}{}{\edef\dc@lstkeywdB{\dc@lstkeywdB,#1}}}, + keywd2style.usage = general, + keywd2style.code = {\ifblank{#1}{\def\dc@lstkeywdBstyle{\bfseries\color{\dc@lstkeywdBcolordefault}}}{\def\dc@lstkeywdBstyle{#1}}}, + + setkeywd3.usage = general, + setkeywd3.code = {\ifblank{#1}{\def\dc@lstkeywdC{}}{\def\dc@lstkeywdC{#1}}}, + keywd3.usage = general, + keywd3.code = {\ifblank{#1}{}{\edef\dc@lstkeywdC{\dc@lstkeywdC,#1}}}, + keywd3style.usage = general, + keywd3style.code = {\ifblank{#1}{\def\dc@lstkeywdCstyle{\bfseries\color{\dc@lstkeywdBcolordefault}}}{\def\dc@lstkeywdCstyle{#1}}}, + + setemph.usage = general, + setemph.code = {\ifblank{#1}{\def\dc@lstemph{}}{\def\dc@lstemph{#1}}}, + emph.usage = general, + emph.code = {\ifblank{#1}{}{\edef\dc@lstemph{\dc@lstemph,#1}}}, + emphstyle.usage = general, + emphstyle.code = {\ifblank{#1}{\def\dc@lstemphstyle{\bfseries\color{\dc@lstemphcolordefault}}}{\def\dc@lstemphstyle{#1}}}, + + setemph2.usage = general, + setemph2.code = {\ifblank{#1}{\def\dc@lstemphB{}}{\def\dc@lstemphB{#1}}}, + emph2.usage = general, + emph2.code = {\ifblank{#1}{}{\edef\dc@lstemphB{\dc@lstemphB,#1}}}, + emph2style.usage = general, + emph2style.code = {\ifblank{#1}{\def\dc@lstemphBstyle{\bfseries\color{\dc@lstemphcolordefault}}}{\def\dc@lstemphBstyle{#1}}}, + + setemph3.usage = general, + setemph3.code = {\ifblank{#1}{\def\dc@lstemphC{}}{\def\dc@lstemphC{#1}}}, + emph3.usage = general, + emph3.code = {\ifblank{#1}{}{\edef\dc@lstemphC{\dc@lstemphC,#1}}}, + emph3style.usage = general, + emph3style.code = {\ifblank{#1}{\def\dc@lstemphCstyle{\bfseries\color{\dc@lstemphcolordefault}}}{\def\dc@lstemphCstyle{#1}}}, + + stringstyle.usage = general, + stringstyle.code = {\ifblank{#1}{\def\dc@lststringstyle{\color{\dc@lststringcolordefault}}}{\def\dc@lststringstyle{#1}}}, + + commentstyle.usage = general, + commentstyle.code = {\ifblank{#1}{\def\dc@lstcommentstyle{\color{\dc@lstcommentcolordefault}}}{\def\dc@lstcommentstyle{#1}}}, + + bckgndcolor.usage = general, + bckgndcolor.code = {\ifblank{#1}{\def\dc@lstbckgndcolor{\color{\dc@lstbckgndcolordefault}}}{\def\dc@lstbckgndcolor{#1}}}, + + rulecolor.usage = general, + rulecolor.code = {\ifblank{#1}{\def\dc@lstrulecolor{\color{\dc@lstrulecolordefault}}}{\def\dc@lstrulecolor{#1}}}, + + numbers.usage = general, + numbers.code = {\ifblank{#1}{\def\dc@lstnumbers{none}}{\def\dc@lstnumbers{#1}}}, + + numberstyle.usage = general, + numberstyle.code = {\ifblank{#1}{\def\dc@lstnumberstyle{\tiny\color{\dc@lstnumbercolordefault}}}{\def\dc@lstnumberstyle{#1}}}, + + parindent.usage = general, + parindent.code = {\setlength\dc@demo@parindent{\parindent}\setdcpar{#1}}, + + default.usage = general, + default.code = {\dc@lstkeysdefault}, +} +\NewDocumentCommand{\setdclisting}{m}{\SetKeys[dclisting]{#1}} +\NewDocumentCommand{\dc@lstkeysdefault}{}{% + \setdclisting{% + settexcs,texcsstyle,settexcs2,texcs2style,settexcs3,texcs3style,% + setkeywd,keywdstyle,setkeywd2,keywd2style,setkeywd3,keywd3style,% + setemph,emphstyle,setemph2,emph2style,setemph3,emph3style,% + stringstyle,commentstyle,bckgndcolor,rulecolor,% + numbers,numberstyle,% + }% +} +\setdclisting{default} + +\DeclareKeys[dcpar]{ + org.usage = general, + org.code = {\setlength\dc@demo@parindent\dc@org@parindent}, + default.usage = general, + default.code = {\setlength\dc@demo@parindent\parindent}, +} +\DeclareUnknownKeyHandler[dcpar]{\ifblank{#1}{\setlength\dc@demo@parindent\dc@org@parindent}{\setlength\dc@demo@parindent{#1}}} + +\NewDocumentCommand{\setdcpar}{m}{\SetKeys[dcpar]{#1}} + +\DeclareKeys[dclisting]{ + codeprefix.usage = general, + codeprefix.code = {\ifblank{#1}{\def\dc@codeprefix{\LaTeX~Code:}}{\def\dc@codeprefix{#1}}}, + + resultprefix.usage = general, + resultprefix.code = {\ifblank{#1}{\def\dc@resultprefix{\LaTeX~Result:}}{\def\dc@resultprefix{#1}}}, + + defaulttools.usage = general, + defaulttools.code = {\SetKeys[dclisting]{codeprefix,resultprefix}} , +} +%\DeclareUnknownKeyHandler[dclisting]{\setdclisting{#1={#2}}} + +%\NewDocumentCommand{\setdctools}{m}{\SetKeys[dctools]{#1}} +\SetKeys[dclisting]{defaulttools} + + + +%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%% +%%% +%%% From doctools.dtx file +%%% lstlistings 'definitions' +%%% +%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%% + +%%% listings +% +\lstdefinestyle{lstStyleDefault}{ +%%% appearance + ,basicstyle=\small\ttfamily % Standardschrift +%%% Space and placement + ,floatplacement=tbp % is used as float place specifier + ,aboveskip=\medskipamount % define the space above and + ,belowskip=\medskipamount % below displayed listings. + ,lineskip=0pt % specifies additional space between lines in listings. + ,boxpos=c % c,b,t +%%% The printed range + ,showlines=false % prints empty lines at the end of listings +%%% characters + ,extendedchars=true % allows or prohibits extended characters + % in listings, that means (national) + % characters of codes 128-255. + ,upquote=true % determines printing of quotes + ,tabsize=2, % chars of tab + ,showtabs=false % do not show tabs + ,showspaces=false % do not show spaces + ,showstringspaces=false % do not show blank spaces in string +%%% Line numbers + ,numbers=none % left, right, none +%%% Captions + ,numberbychapter=true % + ,captionpos=b % t,b + ,abovecaptionskip=\smallskipamount % the vertical space respectively above + ,belowcaptionskip=\smallskipamount % or below each caption +%%% Margins and line shape + ,linewidth=\linewidth % defines the base line width for listings. + ,xleftmargin=0pt % extra margins + ,xrightmargin=0pt % + ,resetmargins=false % indention from list environments like enumerate + % or itemize is reset, i.e. not used. + ,breaklines=true % line breaking of long lines. + ,breakatwhitespace=false % allows line breaks only at white space. + ,breakindent=0pt % is the indention of the second, third, ... + % line of broken lines. + ,breakautoindent=true % apply intendation + ,columns=flexible % + ,keepspaces=true % +} + + +\lstdefinestyle{lstDocStyleBase}{ +%%% base style +% + ,style=lstStyleDefault +%%% appearance + ,commentstyle=\slshape +%%% Line numbers + ,numbers=left % left, right, none + ,stepnumber=1 % seperation between numbers + ,numberfirstline=false % number first line always + ,numberstyle={\dc@lstnumberstyle} % style of numbers + ,numbersep=5pt % distance to text + ,numberblanklines=true % +%%% language + ,language = [LaTeX]TeX +%%% commands + % LaTeX programming + ,moretexcs={setlength,usepackage,newcommand,renewcommand,providecommand,RequirePackage,SelectInputMappings,ifpdftex,ifpdfoutput,AtBeginEnvironment,ProvidesPackage}, + % other commands + ,moretexcs={maketitle,text,includegraphics,chapter,section,subsection, + subsubsection,paragraph,textmu,enquote,blockquote,ding,mathds,ifcsdef,Bra,Ket,Braket,subcaption,lettrine,mdfsetup,captionof,listoffigures,listoftables,tableofcontents,appendix} + % tables + ,moretexcs={newcolumntype,rowfont,taburowcolors,rowcolor,rowcolors,bottomrule, + toprule,midrule,} + % hyperref + ,moretexcs={hypersetup} + % glossaries + ,moretexcs={gls,printglossary,glsadd,newglossaryentry,newacronym} + % Koma + ,moretexcs={mainmatter,frontmatter,geometry,KOMAoptions,setkomafont,addtokomafont} + % SI, unit + ,moretexcs={si,SI,sisetup,unit,unitfrac,micro} + % biblatex package + ,moretexcs={newblock,ExecuteBibliographyOptions,addbibresource} + % math packages + ,moretexcs={operatorname,frac,sfrac,dfrac,DeclareMathOperator,mathcal,underset} + % demo package + ,moretexcs={democodefile,package,cs,command,env,DemoError,PrintDemo} + % tablestyles + ,moretexcs={theadstart,tbody,tsubheadstart,tsubhead,tend} + % code section package + ,moretexcs={DefineCodeSection,SetCodeSection,BeginCodeSection, + EndCodeSection} + % template tools package + ,moretexcs={IfDefined,IfUndefined,IfElseDefined,IfElseUndefined,IfMultDefined,IfNotDraft,IfNotDraftElse,IfDraft,IfPackageLoaded,IfElsePackageLoaded,IfPackageNotLoaded,IfPackagesLoaded,IfPackagesNotLoaded,ExecuteAfterPackage,ExecuteBeforePackage,IfTikzLibraryLoaded,IfColumntypeDefined,IfColumntypesDefined,IfColorDefined,IfColorsDefined,IfMathVersionDefined,SetTemplateDefinition,UseDefinition,IfFileExists,iflanguage} + % tablestyles + ,moretexcs={setuptablefontsize,tablefontsize,setuptablestyle,tablestyle, setuptablecolor,tablecolor,disablealternatecolors, tablealtcolored,tbegin,tbody,tend,thead, theadstart,tsubheadstart,tsubhead,theadrow,tsubheadrow,resettablestyle,theadend,tsubheadend,tableitemize,PreserveBackslash} + % todonotes + ,moretexcs={todo,missingfigure} + % listings + ,moretexcs={lstloadlanguages,lstdefinestyle,lstset} + % index + ,moretexcs={indexsetup} + % glossaries + ,moretexcs={newglossarystyle,glossarystyle,deftranslation,newglossary} + % tikz + ,moretexcs={usetikzlibrary} + % color + ,moretexcs={definecolor,colorlet} + % caption + ,moretexcs={captionsetup,DeclareCaptionStyle} + % floatrow + ,moretexcs={floatsetup} + % doc.sty + ,moretexcs={EnableCrossrefs,DisableCrossrefs,PageIndex,CodelineIndex,CodelineNumbered} + % refereces + ,moretexcs={cref,Cref,vref,eqnref,figref,tabref,secref,chapref} +} + +%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%% +%%% +%%% From doctools.dtx file +%%% lstlistings 'definitions' +%%% +%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%% + + + +\lstloadlanguages{[LaTeX]TeX} +\lstdefinestyle{codestyle}{ +%%% base style + style=lstDocStyleBase, + language=[LaTeX]{TeX}, + numbers=none,%{\dc@lstnumbers},% + %%% colors + rulecolor={\dc@lstrulecolor}, + backgroundcolor={\dc@lstbckgndcolor},% + stringstyle={\dc@lststringstyle}, + commentstyle={\dc@lstcommentstyle}, + framerule=0pt,%0.4pt, + nolol=true, + frame=none, + aboveskip=-2ex, + belowskip=-2ex, + basicstyle=\footnotesize\ttfamily , % Standardschrift + rulesep = 0pt, + breaklines=true, + breakindent=3em, + moretexcs={\dc@lsttexcs}, + moretexcs=[2]{\dc@lsttexcsB}, + moretexcs=[3]{\dc@lsttexcsC}, + texcsstyle=*{\dc@lsttexcsstyle}, + texcsstyle=*[2]{\dc@lsttexcsBstyle}, + texcsstyle=*[3]{\dc@lsttexcsCstyle}, + morekeywords={\dc@lstkeywd}, + morekeywords=[2]{\dc@lstkeywdB}, + morekeywords=[3]{\dc@lstkeywdC}, + keywordstyle={\dc@lstkeywdstyle}, + keywordstyle=[2]{\dc@lstkeywdBstyle}, + keywordstyle=[3]{\dc@lstkeywdCstyle}, + emph={\dc@lstemph}, + emph=[2]{\dc@lstemphB}, + emph=[3]{\dc@lstemphC}, + emphstyle={\dc@lstemphstyle}, + emphstyle=[2]{\dc@lstemphBstyle}, + emphstyle=[3]{\dc@lstemphCstyle}, +} +\lstset{style=codestyle} + +%%% +%%% Using scontents package !!!! +%%% +\ExplSyntaxOn +\keys_define:nn { scontents / scontents} + { + st.meta:nn = { scontents } { store-env = #1 }, + st.value_required:n = true + } +\ExplSyntaxOff + +\newenvsc{stcode} +\let\verbatimsc\@undefined +\let\verbatimsc@\@undefined +\let\endverbatimsc\@undefined +\lstnewenvironment{verbatimsc}{\lstset{style=codestyle}}{} + + +\NewDocumentEnvironment{verbsc}{m}{% + \let\verbatimsc\@undefined + \let\verbatimsc@\@undefined + \let\endverbatimsc\@undefined + \setdclisting{#1} + \edef\dc@tmp{style=codestyle,moretexcs={\dc@lsttexcs},moretexcs=[2]{\dc@lsttexcsB},moretexcs=[3]{\dc@lsttexcsC},% + morekeywords={\dc@lstkeywd},morekeywords=[2]{\dc@lstkeywdB},morekeywords=[3]{\dc@lstkeywdC},% + emph={\dc@lstemph},emph=[2]{\dc@lstemphB},emph=[3]{\dc@lstemphC},% + numbers={\dc@lstnumbers}} + \lstnewenvironment{verbatimsc}{\expandafter\lstset\expandafter{\dc@tmp}}{} +}{% +} + +\NewDocumentCommand{\DisplayCodeB}{O{}m}{% + {% + \begin{verbsc}{#1}% + \begin{tabular}{J{.98\textwidth}}\dc@codeprefix \\ + \typestored{#2}% + \end{tabular}% + \end{verbsc}% + }% +} + +\NewDocumentCommand{\DemoCodeB}{O{}m}{{% + \setlength\parindent\dc@org@parindent + \begin{verbsc}{#1}% + \begin{tabular}{J{.98\textwidth}}% + \dc@codeprefix \\% + \typestored{#2}\\% + \end{tabular}% + + \begin{tabular}{J{.98\textwidth}}% + \dc@resultprefix \\\hline\\[-1ex]% + \getstored{#2}\\\hline% + \end{tabular}% + \end{verbsc}% +}} + +\NewDocumentCommand{\TabbedDemoCodeB}{O{}m}{{% + \setlength\parindent\dc@org@parindent + \begin{verbsc}{#1}% + \arrayrulecolor{gray} + \begin{tabular}{J{.49\textwidth}@{}J{.49\textwidth}}% + \dc@codeprefix & \dc@resultprefix\\\hline\\[-1ex]% + \typestored{#2} & \getstored{#2}\\\hline% + \end{tabular}% + \end{verbsc}% +}} + + +\NewDocumentCommand{\DisplayCode}{O{}m}{{% + \begin{verbsc}{#1}% + \vspace*{0.5ex} + \begin{minipage}{1\textwidth}\dc@codeprefix \\ + \typestored{#2}% + \end{minipage}% + \\[1.5ex]% + \end{verbsc}% +}} + +\NewDocumentCommand{\DemoCode}{O{}mO{1ex}}{{% + \begin{verbsc}{#1}% + \vspace*{1ex} + \begin{minipage}{1\textwidth}\dc@codeprefix \\ + \typestored{#2}% + \end{minipage}% + \\[3ex] + \begin{minipage}{1\textwidth}% + \dc@resultprefix \\[-1.5ex]% + \rule{\textwidth}{0.2pt}\vspace*{0.75ex}% + \setlength\parindent\dc@demo@parindent% + + \getstored{#2}% + \end{minipage}% + \\[#3]% + \rule{1\textwidth}{0.2pt}%\vspace*{0.25ex} + \end{verbsc}% +}} + +\NewDocumentCommand{\TabbedDemoCode}{O{}mO{1ex}}{{% + \begin{verbsc}{#1}% + \begin{minipage}{.5\textwidth}% + \dc@codeprefix% + \end{minipage}% + \begin{minipage}{.5\textwidth}% + \dc@resultprefix% + \end{minipage}\\[-1.5ex]% + \rule{\textwidth}{0.2pt}\vspace*{1ex}% + + \begin{minipage}{.5\textwidth}\vspace*{2ex}% + \typestored{#2}\vspace*{1.5ex}% + \end{minipage}% + \begin{minipage}{.5\textwidth}% + \setlength\parindent\dc@demo@parindent% + \getstored{#2}% + \end{minipage}% + \\[#3]% + \rule{1\textwidth}{0.2pt}%\vspace*{0.5ex} + \end{verbsc}% +}} +%%% +%%% Using scontents package !!!! +%%% + + +%%% +%%% from https://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings#Encoding_issue +\lstset{literate= + {á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1 + {Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1 + {à}{{\`a}}1 {è}{{\`e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1 + {À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1 + {ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1 + {Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1 + {â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1 + {Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1 + {ã}{{\~{a}}}1 {õ}{{\~{o}}}1 + {Ã}{{\~{A}}}1 {Õ}{{\~{O}}}1 + {ý}{{\'{y}}}1 {Ý}{{\'{Y}}}1 {ÿ}{{\"{y}}}1 {Ÿ}{{\"{Y}}}1 + {œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1 + {ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1 + {€}{{\EUR}}1 {£}{{\pounds}}1 +} + +\endinput |