diff options
author | Karl Berry <karl@freefriends.org> | 2011-12-21 23:43:42 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-12-21 23:43:42 +0000 |
commit | 96d75501059aaba75f35e407391703be9cf3b21f (patch) | |
tree | 5bc7357d078ee23aab948474cc9edfc1fd043589 /Master/texmf-dist/tex/latex/ltxtools/ltxtools-doc.sty | |
parent | e9250f00ffb6069748594707c033a97104a3c7b9 (diff) |
ltxtools 0.0.1a (19dec11)
git-svn-id: svn://tug.org/texlive/trunk@24897 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/ltxtools/ltxtools-doc.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/ltxtools/ltxtools-doc.sty | 1318 |
1 files changed, 1318 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/ltxtools/ltxtools-doc.sty b/Master/texmf-dist/tex/latex/ltxtools/ltxtools-doc.sty new file mode 100644 index 00000000000..de7902ea380 --- /dev/null +++ b/Master/texmf-dist/tex/latex/ltxtools/ltxtools-doc.sty @@ -0,0 +1,1318 @@ +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% +% % +% This is file 'ltxtools-doc.sty', version 0.0.1, December 2011. % +% % +% This package and accompanying files may be distributed and/or % +% modified under the conditions of the LaTeX Project Public License, % +% either version 1.3 of this license or 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. % +% % +% The LPPL maintenance status of this software is 'author-maintained'. % +% % +% This software is provided 'as it is', without warranty of any kind, % +% either expressed or implied, including, but not limited to, the % +% implied warranties of merchantability and fitness for a particular % +% purpose. % +% % +% Copyright (c) 2011 Ahmed Musa (amusa22@gmail.com). % +% % +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% + +\@ifpackageloaded{ltxtools}{% + \@ifpackagelater{ltxtools}{2011/11/12}{}{% + \@latex@error{Loaded version of ltxtools package is + not current}\@ehc + }% +}{% + \RequirePackage{ltxtools}[2011/12/12]% +} +\UseNormalCatcodes +\StyleFilePurpose{Macros and interfaces for document body (AM)} +\StyleFileRCSInfo +$Id: ltxtools-doc.sty,v 0.0.1 2011/12/12 09:00:00 Ahmed Musa Exp $ +\ProvidesPackage{ltxtools-doc}[\StyleFileInfo] +\NeedsTeXFormat{LaTeX2e}[2011/06/27] +\cptloadpackages{% + ltxkeys||2011/12/10; +} +\robust@def*\useshortdoccmds{% + \let\useshortdoccmds\relax + \def\do##1##2,{% + \ifnot@nil{##1}{% + \ifdefTF{##1}{% + \ifx##1##2\else + \LTS@err{Command '\string##1' already exists:\MsgBrk + it can't be redefined by \string\useshortdoccmds}\@ehc + \fi + }{% + \let##1=##2% + }% + \do + }% + }% + \expandafter\do\LTS@shortdoccmds,\@nil,% +} +\begingroup +\endlinechar=-1 +\robust@gdef*\LTS@shortdoccmds{% + \cmdtext\ltscmdtext, + \fx\ltsfx,\ffx\ltsffx,\ffxi\ltsffxi,\ffxim\ltsffxim, + \ftffx\ltsftffx,\hx\ltshx,\hhx\ltshhx, + \fthhx\ltsfthhx,\ftfx\ltsftfx,\ftfxx\ltsftfxx,\fxim\ltsfxim, + \fxi\ltsfxi,\fxis\ltsfxis,\hxim\ltshxim,\hxi\ltshxi,\hxis\ltshxis, + \dummyfxim\ltsdummyfxim,\dummyfxi\ltsdummyfxi,\aidx\ltsaidx, + \aidxm\ltsaidxm,\aidxs\ltsaidxs,\bidx\ltsbidx,\bidxm\ltsbidxm, + \bidxs\ltsbidxs,\aiidx\ltsaiidx,\aiidxm\ltsaiidxm,\aiidxs\ltsaiidxs, + \files\ltsfiles,\file\ltsfiles,\headpkg\ltsheadpkg,\emphlist\ltsemphlist, + \quotedlist\ltsquotedlist,\pkg\ltspkg,\pkgm\ltspkgm,\pkgg\ltspkgg, + \pkgnoidx\ltspkgnoidx,\pkgs\ltspkgs, + \headquoted\ltsheadquoted,\headfx\ltsheadfx,\headhx\ltsheadhx, + \noteenv\ltsnoteenv,\endnoteenv\endltsnoteenv +} +\endgroup + +\robust@def*\LTS@sanitize{% + \let\do\@makeother + \do\\\do\$\do\&\do\#\do\^\do\_\do\%\do\~% +} +\robust@def*\ltshref{% + \begingroup + \LTS@sanitize\@makeother\|% + \expandafter\endgroup\LTS@href@a +} +\robust@def*\LTS@href@a#1{% + \edef\LTS@tempa{\cptzapspaces{#1}}% + \LTS@href@b +} +\robust@def*\LTS@href@b#1{\href{\LTS@tempa}{#1}} + +\robust@def*\LTS@writefile#1#2{% + \ifblankTF{#2}{}{% + \if@filesw + \@bsphack + \immediate\write#1{\unexpanded{#2}}% + \if@nobreak\ifvmode\nobreak\fi\fi + \@esphack + \fi + }% +} +\robust@def*\ltsensurecomma{% + \ltsifnextchar,{}{\LTS@err{Don’t forget comma}}% +} +\robust@def*\ltsmakecs#1{\texttt{\char'134\unskip#1}} +\robust@def*\ltsnohyphens{\hyphenpenalty\@M\exhyphenpenalty\@M} +\robust@def*\ltsdefinecolor{% + \let\reserved@e\definecolor + \LTS@testopt\LTS@definecolor{}% +} +\robust@def*\ltscolorlet{% + \let\reserved@e\colorlet + \LTS@testopt\LTS@definecolor{}% +} +\robust@def*\LTS@definecolor[#1]#2{% + \@ifundefinedcolor{#2}{% + \reserved@e[#1]{#2}% + }{% + \LTS@err{Color name '#2' already defined}\@ehc + }% +} +% Usage of colors defined via \ltsdefinecolorset: +% eg, \color{<head>green<tail>}, where <head>->x, <tail>->1. +\robust@def*\ltsprovidecolorset{% + \begingroup + \let\inprovide\cptswtrue + \LTS@testopt\LTS@definecolorset{x}% +} +\robust@def*\ltsdefinecolorset{% + \begingroup + \let\inprovide\cptswfalse + \LTS@testopt\LTS@definecolorset{x}% +} +\robust@def*\LTS@definecolorset[#1]{% + \cpt@testpnopt{\LTS@d@finecolorset{#1}}{1}% +} +\robust@def*\LTS@d@finecolorset#1(#2)#3{% + \ifcsndefTF{ver@xcolor.sty}{}{% + \LTS@err{'xcolor' package not loaded}\@ehc + }% + \cptemptifycsset{\LTS@tempb,\LTS@tempc,\LTS@tempd,\LTS@tempe}% + \def\LTS@tempa##1,##2,##3,##4,##5\@nil{% + \ifblankTF{##4}{% + \LTS@err{Incomplete color format in \string\ltsdefinecolorset}\@ehc + }{% + \def\reserved@e{##1}% + }% + }% + \def\csv@do##1{% + \LTS@tempa##1,,,,\@nil + \xifinsetTF{,\reserved@e,}{,\LTS@tempd,}{% + \edef\LTS@tempe{\csliststack,\LTS@tempe\reserved@e}% + }{% + \edef\LTS@tempd{\csliststack,\LTS@tempd\reserved@e}% + \@ifundefinedcolor{#1\reserved@e#2}{% + \edef\LTS@tempb{\csliststack;\LTS@tempb##1}% + }{% + \if\inprovide\else + \edef\LTS@tempc{\csliststack{;\@space}\LTS@tempc#1\reserved@e#2}% + \fi + }% + }% + }% + \csv@@parse[;]{#3}% + \ifcsemptyTF\LTS@tempe{}{% + \LTS@err{Color names '\expandcsonce\LTS@tempe' multiply + \MsgBrk submitted to \string\ltsdefinecolorset}\@ehc + }% + \ifcsemptyTF\LTS@tempc{}{% + \LTS@err{Color names '\LTS@tempc' already in use}\@ehc + }% + \ifcsemptyTF\LTS@tempb{}{% + \cptexpandarg{\xglobal\definecolorset{rgb}{#1}{#2}} + {\expandcsonce\LTS@tempb}% + }% + \endgroup +} +\robust@def*\startrecurrentlist#1{% + \gdef\recurlistnr{#1}% + \simplecmdpatch\@item{% + \if@nmbrlist\refstepcounter\@listctr\fi + }{% + \if@nmbrlist + \refstepcounter\@listctr + \ifnum\csname c@\@listctr\endcsname>#1% + \advance\csname c@\@listctr\endcsname-#1% + \fi + \fi + }% +} +\robust@def*\@endrecurlist#1{% + \simplecmdpatch\@item{% + \if@nmbrlist + \refstepcounter\@listctr + \ifnum\csname c@\@listctr\endcsname>#1% + \advance\csname c@\@listctr\endcsname-#1% + \fi + \fi + }{% + \if@nmbrlist\refstepcounter\@listctr\fi + }% +} +\robust@def*\endrecurrentlist{% + \ifdefTF\recurlistnr{}{% + \ltxmsg@err{'\string\startrecurrentlist' wasn't called before + \MsgBrk'\string\endrecurrentlist'}\@ehc + }% + \simpleexpandarg\@endrecurlist\recurlistnr + \gundefcs\recurlistnr +} + +% Eg, \uppercasefirstletter{ 0a ahmed musa } +\new@def*\LTS@nouppercaselist{a,an,any,and,or,not,for,from, + if,the,then,them,they,he,she,will,would,shall} +\robust@def*\AddToNoUppercaseList#1{% + \ltsfiltermergecsv[,]\LTS@nouppercaselist{#1}\nofilter +} +\new@def*\uppercasefirstletter#1{% + \begingroup + \@tempcnta\z@pt + \let\LTS@tempa\@empty + \expandafter\upp@rcasefirstletter\romannumeral-`\q#1 \@nil +} +\new@def*\upp@rcasefirstletter#1 #2\@nil{% + \oifinset@sp@TF,{#1}\LTS@nouppercaselist{% + \ifnum\@tempcnta=\z@pt + \upp@rc@sefirletter#1\@nil + \else + \LTS@tempa#1% + \fi + }{% + \upp@rc@sefirletter#1\@nil + }% + \advance\@tempcnta\@ne + \ifblankTF{#2}{% + \endgroup + }{% + \let\LTS@tempa\@space + \upp@rcasefirstletter#2 \@nil + }% +} +\new@def*\upp@rc@sefirletter#1#2\@nil{\uppercase{\LTS@tempa#1}#2} + +\AtBeginDocument{\newcounter{LTS@notecnt}[section]} +% For use where \@currentlabel is needed: +\robust@def*\ltsnoteenv{\cpt@testst\LTS@noteenv} +\robust@def*\LTS@noteenv{% + \let\if@notest\ifcpt@st + \stepcounter{LTS@notecnt}% + \protected@edef\@currentlabel{\thesection.\theLTS@notecnt}% + \def\@currentlabelname{note}% + \def\@currentHref{note.\@currentlabel}% + \smallbreak + \textbf{Note~\thesection.\theLTS@notecnt}\enskip + \nobreak\@nobreaktrue +} +\robust@def*\endltsnoteenv{% + \finalhyphendemerits\z@pt + \if@notest\unskip\textbullet\fi + \medbreak\@ignoretrue +} +\robust@def*\ltsnote{% + \stepcounter{LTS@notecnt}% + \smallbreak + \textbf{Note~\thesection.\theLTS@notecnt}\enskip + \nobreak\@nobreaktrue +} +\newenvironment{indentednote}{% + \stepcounter{LTS@notecnt}% + \protected@edef\@currentlabel{\thesection.\theLTS@notecnt}% + \def\@currentlabelname{note}% + \def\@currentHref{note.\@currentlabel}% + \nobreak\@nobreaktrue + \list{}{\listparindent1.5em\relax + \itemindent\listparindent\rightmargin\leftmargin + \parsep\z@pt\relax + \ifcsndefTF{ver@amverbatim.sty}{% + \vbleftmargin\leftmargin + \vbrightmargin\rightmargin + }{}% + }% + \item\hspace*{-\itemindent}% + \textbf{Note~\thesection.\theLTS@notecnt}\enskip +}{% + \endlist\medskip\@ignoretrue +} + +\patchcs\@afterheading + {\clubpenalty \@clubpenalty} + {\clubpenalties 2 \@clubpenalty 0}{}{} +\gnewletcs\rsv@afterheading\@afterheading +\lastlinefit500 +\robust@def*\docsection{% + \begingroup + \LTS@testst{\LTS@section\section}% +} +\robust@def*\docsubsection{% + \begingroup + \LTS@testst{\LTS@section\subsection}% +} +\robust@def*\docsubsubsection{% + \begingroup + \LTS@testst{\LTS@section\subsubsection}% +} +\robust@def*\docparagraph{% + \begingroup + \LTS@testst{\LTS@section\paragraph}% +} +\robust@def*\LTS@section#1{% + \edef\LTS@tempa{\noexpand#1\ifLTS@st*\fi}% + \cpt@testpnopt\LTS@s@ction{}% +} +\robust@def*\LTS@s@ction(#1){% + \cpt@testltopt{\LTS@s@cti@n{#1}}{}% +} +\robust@def*\LTS@s@cti@n#1<#2>{% + \xdef\@afterheading{% + \ifblankTF{#1}{}{\unexpanded{\label{#1}}}% + \ifblankTF{#2}{}{\unexpanded{\ltsaidxm*{#2}}}% + \expandcsonce\@afterheading + \gletcs\noexpand\@afterheading\noexpand\rsv@afterheading + }% + \expandafter\endgroup\LTS@tempa +} +\new@def*\ltsreddots#1#2{% + \begin{center}% + \def\tempa{\textcolor{red}{\vrule height1ex depth0pt width1ex}}% + \tempa\hspace{#1cm}{#2}\hspace{#1cm}\tempa + \end{center}% +} +\ltxkeys@definekeys*[LTS]{citation}[ctt@]{% + width/\hsize; + author//; + textcolor/black; + fonttype/\normalfont; + leftmargin/\leftmargin; + rightmargin/\rightmargin; + preskip/0ex +} +\ltsprotected\ltsnewcommand\ltscitation[2][]{% + \ltxkeys@launchkeys[LTS]{citation}{#1}% + \begingroup + \sbox\@tempboxa{% + \ctt@fonttype + \textit{\textcolor{\ctt@textcolor}{\ctt@author}}% + }% + \list{}{% + \setlength\leftmargin{\ctt@leftmargin}% + \setlength\rightmargin{\ctt@leftmargin}% + }% + \vspace*{\ctt@preskip}% + \item\relax\ignorespaces + \ctt@fonttype\textcolor{\ctt@textcolor}{#2}% + \hspace*{\fill}\nolinebreak[1]% + \quad\hspace*{\fill}\finalhyphendemerits\z@pt\relax + \usebox{\@tempboxa}% + \endlist + \bigskip + \endgroup + \@ignoretrue +} +\new@def*\fnquote@finalstrut#1{% + \unskip + \ifhmode + \nobreak + \vrule\@width\z@\@height\z@\@depth\dp#1% + \fi +} +\newenvironment{ltsfnquote}[1][0pt]{% + \begin{list}{}{% + \vspace*{-#1}% + \setmanytolength{\topsep,\parskip,\partopsep,\itemsep}{0em}% + }% + \item\relax +}{% + \fnquote@finalstrut\strutbox + \end{list}% +} +\ltxkeys@definekeys*[LTS]{ltsshade}[ltsshd@]{% + width/\hsize; + leftadjust/0em; + indent/0em; + fillcolor/gray!25; + framecolor/black; + framesep/3\p@; + framerule/0.4\p@ +} +\robust@def*\LTS@shadedenv{% + \def\FrameCommand{% + \clubpenalty\@m\widowpenalty\@m + \noindent\kern\ltsshd@leftadjust + \fboxrule\ltsshd@framerule\fboxsep\ltsshd@framesep + \fcolorbox{\ltsshd@framecolor}{\ltsshd@fillcolor}% + }% + \parindent\z@pt\finalhyphendemerits\z@pt + \dimensionexpr\dimen@{\ltsshd@width-(\ltsshd@framesep + +\ltsshd@framerule+\ltsshd@indent)}% + \MakeFramed{\hsize\dimen@\FrameRestore\@setminipage}% +} +\newcommand\ltsframeshade[1][]{% + \ifcsndefTF{ver@framed.sty}{% + \ltxkeys@launchkeys[LTS]{ltsshade}{#1}% + \LTS@shadedenv + }{% + \ltxmsg@err{'framed' package not loaded}\@ehc + }% +} +\robust@def*\endltsframeshade{\endMakeFramed\@ignoretrue} +\robust@def*\ltsframewithtitle{\LTS@testst\LTS@framewithtitle} +\robust@def*\LTS@framewithtitle{% + \vskip.5\baselineskip + \begin{ltsframeshade}[width=\fwt@width,fillcolor=\fwt@color, + framesep=\fwt@framesep,framerule=\fwt@framerule, + framecolor=\fwt@framecolor]% + \ifLTS@st\else + \textcolor{\fwt@titlecolor}{\fwt@format{\fwt@title}}% + \\[\fwt@titlevskip]% + \fi + \endgraf +} +\def\endframewithtitle{% + \end{ltsframeshade}\ignorespaces\@ignoretrue +} +\newcommand*\lipsumnopar[2][1]{{\def\lips@par{ }\lipsum[#1-#2]}} +\robust@def*\LTS@lipsumcolors{% + black,red,blue,green,purple,cyan,violet,orange% +} +\robust@def*\AddLipsumColors#1{% + \ltsfiltermergecsv[,]\LTS@lipsumcolors{#1}\nofilter +} +\robust@def*\ltslipsum{% + \ifcsndefTF{ver@lipsum.sty}{% + \ifcsndefTF{ver@xcolor.sty}{% + \LTS@testopt{\LTS@lipsum}{1}% + }{% + \ltxmsg@err{'xcolor' package not loaded}\@ehc + }% + }{% + \ltxmsg@err{'lipsum' package not loaded}\@ehc + }% +} +\robust@def*\LTS@lipsum[#1]{% + \pushnumber\LTS@lipsumnr + \begingroup + \@tempcnta\z@pt + \def\currcolor{}% + \def\do##1,{% + \iftokennilTF{##1}{% + \ifcsemptyTF\currcolor{% + \expandafter\do\LTS@lipsumcolors,\@nil,% + }{}% + }{% + \advance\@tempcnta by1 + \let\next\do + \ifnum\@tempcnta=\LTS@lipsumnr + \def\currcolor{##1}% + \def\next####1\@nil,{}% + \fi + \next + }% + }% + \expandafter\do\LTS@lipsumcolors,\@nil,% + \noindent\textcolor{\currcolor}{\lipsum[#1]}% + \endgroup + \smallskip +} +\new@def*\LTS@baselineskip{} +\newenvironment{ltssidetoks}[2][\marginparwidth]{% + \xdef\LTS@baselineskip{\the\dimexpr#2{\LTS@baselineskip}}% + \list{}{\leftmargin-#1}% + \nobreak\@nobreaktrue + \vspace{.5ex}% + \item[]\relax +}{% + \endgraf\nobreak\@nobreaktrue + \def\reserved@a##1##{##1\gdef\LTS@baselineskip}% + \advance\baselineskip-\expandafter\reserved@a\LTS@baselineskip + \endlist + \removelastskip +} + +\robust@def*\srefsetup#1{% + \ltxkeys@launchkeys[LTS]{ltsref}{#1}% +} +% Examples: +% \sref[sec:]{y,x,z} +% \sref*[sec:]{y,x,z} +% \srefrange[sec:]{y,x,z} +% \sref will list all the references in ascending order; +% \srefrange will list only the smallest and largest references, +% joined with a hyphen; \sref* is equivalent to \srefrange. +\robust@def*\sref{% + \begingroup + \let\LTS@inrefrng\cptswfalse + \cpt@teststopt\LTS@ref@a{}% +} +\robust@def*\srefrange{% + \begingroup + \let\LTS@inrefrng\cptswtrue + \LTS@testopt\LTS@ref@a{}% +} +\robust@def*\LTS@ref@a[#1]{% + \ifcsndefTF{ver@hyperref.sty}{}{% + \ltxmsg@warn{Package 'hyperref' not loaded: + \MsgBrk'\noexpand\sref' and '\noexpand\srefrange' can't + \MsgBrk extract reference name automatically}% + }% + \if\LTS@inrefrng\else + \ifcpt@st + \let\LTS@inrefrng\cptswtrue + \fi + \fi + \def\refbase{#1}\LTS@ref@b +} +\robust@def*\LTS@ref@b#1{% + \edef\x{\s@expandarg\cpttrimspace{\cptrm-`\q#1}}% + \ifcsemptyTF\x{}{% + \cptexpandarg\LTS@ref@c\x + }% +} +\robust@def*\LTS@ref@c#1{% + \ifcsemptyTF\refbase{% + \def\LTS@reflist{#1}% + }{% + \def\LTS@reflist{}% + \cptfor#1\dofor{% + \edef\LTS@reflist{\csliststack,\LTS@reflist\refbase##1}% + }% + }% + \def\LTS@tempa##1,##2,##3\@nil{% + \ifblankTF{##2}{% + \edef\LTS@tempa{\cpttrimspace{##1}}% + \ifdefTF\autoref\autoref\ref\LTS@tempa + }{% + \expandafter\LTS@ref@d\expandafter{\LTS@reflist}% + }% + }% + \expandafter\LTS@tempa\LTS@reflist,,\@nil + \endgroup +} +\robust@def*\LTS@ref@d#1{% + \let\ifnumtest\ifnnum + \def\LTS@reflist{}\def\LTS@r@flist{}% + \def\putref##1{% + \def\reserved@a####1##1####2####3\LTS@nil{% + \ref{####2}% + }% + \expandafter\reserved@a\LTS@r@flist\LTS@nil + }% + \def\do##1{% + \edef\LTS@reflist{\LTS@reflist{\LTS@getrefnum{##1}}}% + \edef\LTS@r@flist{\LTS@r@flist\LTS@getrefnum{##1}{##1}}% + \ifnumcmpTF\indrisnr>\@ne{% + \ifboolFT{lastindris}{}{% + \ifswitchTF{LTS@inrefrng}{% + \LTS@setrefrange\LTS@reflist + }{% + \def\sortoutputfmt####1{####1,}% + \def\sortendfmt####1{####1}% + \edef\LTS@reflist{\s@expandarg\ltssortnumlt\LTS@reflist}% + \def\do####1{% + \ifnum\indrisnr>\@ne + \iflastindris + \xifstrcmpTF\LTS@lastrefsep{and}{ and }{, }% + \else + ,\@space + \fi + \fi + \putref{####1}% + }% + \indrisloop*\LTS@reflist\do + }% + }% + }{% + \LTS@getrefname{##1}\if@tempswa s~\fi + }% + }% + \indrisloop{#1}\do +} +\def\LTS@setrefrange#1{% + \def\sortoutputfmt##1{{##1}}% + \def\sortendfmt##1{{##1}}% + \edef#1{\s@expandarg\ltssortnumlt#1}% + \def\LTS@tempa##1##2\LTS@nil{% + \putref{##1}% + \xifstrcmpTF\LTS@refrangesep{--}{--}{% + ~% + \ifnum\indrisnr=\tw@ and\else\LTS@refrangesep\fi + ~% + }% + \def\reverse####1####2{% + \expandafter\ifx\expandafter\LTS@nnil\cpt@car####2\car@nil + \expandafter\iofii\else\expandafter\iiofii\fi + {####1}{% + \expandafter\reverse\expandafter{% + \romannumeral-`\q\ifblankTF{####1}{{####2}}{{####2}####1}% + }% + }% + }% + \edef\LTS@tempb{\reverse{}##2\LTS@nnil}% + \def\LTS@tempa####1####2\LTS@nil{% + \putref{####1}% + }% + \expandafter\LTS@tempa\LTS@tempb\LTS@nil + }% + \expandafter\LTS@tempa#1\LTS@nil +} + +\def\LTS@getrefnum#1{% + \ifcsndefTF{r@#1}{% + \expandafter\expandafter\expandafter + \cpt@car\csname r@#1\endcsname\car@nil + }{% + 00% + }% +} +\def\LTS@getrefname#1{% + \@tempswafalse + \ifcsndefFT{r@#1}{}{% + \expandafter\expandafter\expandafter\LTS@getrefname@a + \csname r@#1\endcsname{}{}{}{}\LTS@nil + }% +} +\def\LTS@getrefname@a#1#2#3#4#5\LTS@nil{% + \ifblankTF{#4}{}{\LTS@getrefname@b#4.\LTS@nil}% +} +\def\LTS@getrefname@b#1.#2\LTS@nil{% + \ifcsndefTF{LTS@#1refname}{% + \@tempswatrue + \csname LTS@#1refname\endcsname + }{% + \ifcsndefTF{#1name}{% + \@tempswatrue + \cptexpanded{\cptsevenxp\cpttrimspaces + \cptthreexp{\csname#1name\endcsname}}% + }{}% + }% +} +\ltxkeys@definekeys*[LTS]{ltsref}[LTS@]{% + equationrefname/Equation/\def\equationautorefname{#1}; + footnoterefname/footnote/\def\footnoteautorefname{#1}; + itemrefname/item/\def\itemautorefname{#1}; + figurerefname/Figure/\def\figureautorefname{#1}; + tablerefname/Table/\def\tableautorefname{#1}; + partrefname/Part/\def\partautorefname{#1}; + appendixrefname/Appendix/\def\appendixautorefname{#1}; + chapterrefname/chapter/\def\chapterautorefname{#1}; + sectionrefname/section/\def\sectionautorefname{#1}; + subsectionrefname/subsection/\def\subsectionautorefname{#1}; + subsubsectionrefname/subsubsection/\def\subsubsectionautorefname{#1}; + paragraphrefname/paragraph/\def\paragraphautorefname{#1}; + subparagraphrefname/subparagraph/\def\subparagraphautorefname{#1}; + noterefname/note/\def\noteautorefname{#1}; + tablenoterefname/table note/\csndef*{table noteautorefname}{#1}; + FancyVerbLinerefname/line/\def\FancyVerbLineautorefname{#1}; + macrolinerefname/macro line/\csndef*{macro lineautorefname}{#1}; + theoremrefname/Theorem/\def\theoremautorefname{#1}; + pagerefname/page/\def\pageautorefname{#1}; + lastrefsep/and/\trim@@spaces{#1}\LTS@lastrefsep; + refrangesep/to/\trim@@spaces{#1}\LTS@refrangesep; +} +\def\setupcrefformat{% + \docommalist{algorithm,appendix,chapter,corollary,definition, + enumi,equation,example,figure,footnote,lemma,line,note,part, + proposition,remark,result,section,table,theorem + }{% + \crefformat{##1}{####2##1~####1####3}% + }% +} +\robust@def*\printcommalist{\cpt@testst\lts@printcommalist} +\robust@def*\lts@printcommalist#1{% + \cpt@stchoose{cpt@st}{#1}\lts@tempa\printcommalist + \def\do##1{% + \ifnum\indrisnr>\@ne + \iflastindris\@space and\@space\else,\@space\fi + \fi + ##1% + }% + \indrisloop*\lts@tempa\do +} +\robust@def*\ltsnobreakitem{\cpt@teststopt\lts@nobreakitem} +\robust@def*\lts@nobreakitem[#1]#2{% + \item~\nopagebreak\\[-\baselineskip]% + \ifcpt@st + \centerline{\includegraphics[#1]{#2}}% + \else + #2% + \fi +} +\newtog{normallongtable} +\AfterStartOfDocument{% + \ifdefTF\LT@start{% + \patchcs\LT@start + {\vfil\break} + {\iftogTF{normallongtable}{\vfil\break}{}} + {\LTS@info{Patching of \noexpand\longtable succeeded}} + {\LTS@warn{Patching of \noexpand\longtable failed}}% + \patchcs\LT@start + {\penalty\z@} + {\iftogTF{normallongtable}{\penalty\z@}{}} + {\LTS@info{Patching of \noexpand\longtable succeeded}} + {\LTS@warn{Patching of \noexpand\longtable failed}}% + }{}% +} +\robust@def\ltsnewfootnote#1{\newcsndef*{LTS@footnote@#1}} +\newcommand*\usefootnote[1]{% + \footnote{\uselivecsn{LTS@footnote@#1}}% + \AtEndDocument{\letcsntocs{LTS@footnote@#1}\relax}% +} +\AtBeginDocument{\newcounter{LTS@ltablenotecnt}[table]} +\new@def\ltablenotehead#1{\noalign{\LTS@ltablenotehead{#1}}} +\robust@def*\LTS@ltablenotehead{% + \def\ltnotehead{00}% + \LTS@teststopt\LTS@ltablenote{}% +} +\new@def*\LTS@ltablenoteshook{} +\robust@def*\ltablenote{% + \def\ltnotehead{01}% + \LTS@teststopt\LTS@ltablenote{}% +} +\robust@def*\LTS@ltablenote[#1]#2{% + \unskip + \ifblankTF{#1}{}{\label{#1}}% + \begin{LTS@uselt@blenote}{#2}\end{LTS@uselt@blenote}% +} +\robust@def\newltablenote#1{\newcsndef*{LTS@ltablenote@id@#1}} +\robust@def*\useltablenote{% + \def\ltnotehead{01}\LTS@teststopt\LTS@useltablenote{}% +} +\robust@def*\LTS@useltablenote[#1]#2{% + \unskip + \ifcsndefTF{LTS@ltablenote@id@#2}{% + \ifblankTF{#1}{}{\label{#1}}% + \begin{LTS@uselt@blenote}% + {\usename{LTS@ltablenote@id@#2}}% + \end{LTS@uselt@blenote}% + \AtEndDocument{\letcsntocs{LTS@ltablenote@id@#2}\relax}% + }{% + \LTS@err{Table note '#2' is undefined}\@ehc + }% +} +\cptnewvariables{dimen}{ltnotenrwidth}[14pt] +\newenvironment{LTS@uselt@blenote}[1]{% + \if\ltnotehead\else + \stepcounter{LTS@ltablenotecnt}% + \ifcsndefTF{ver@hyperref.sty}{% + \protected@edef\@currentlabel{\thetable.\theLTS@ltablenotecnt}% + \def\@currentlabelname{tablenote}% + \def\@currentHref{table note.\@currentlabel}% + }{% + \let\hyperlink\@secondoftwo + \let\hypertarget\@secondoftwo + }% + \@killglue + \hyperlink{hy@ltablenote\thetable.\theLTS@ltablenotecnt}{% + \textsuperscript{% + \ifnum\theLTS@ltablenotecnt=1 See note~\fi + \thetable.\theLTS@ltablenotecnt + }% + }% + \fi + \xdef\LTS@ltablenoteshook{% + \noindent + \expandcsonce\LTS@ltablenoteshook + \if\ltnotehead + \unexpanded{{\noexpand\normalfont\small#1}}% + \endgraf + \else + \ifLTS@st\else\endgraf\fi + \noexpand\makebox[\the\ltnotenrwidth]\ifLTS@st[r]\else[l]\fi{% + \noexpand + \hypertarget{hy@ltablenote\thetable.\theLTS@ltablenotecnt}{% + \noexpand\textsuperscript{\noexpand + \textcolor{blue}{\thetable.\theLTS@ltablenotecnt}% + }% + }% + \ifLTS@st\else\hfill\fi + }% + \unexpanded{#1}% + \fi + }% +}{% + \@ignoretrue +} +\robust@def*\printltablenotes{% + \begingroup + \clubpenalty\@m\widowpenalty\@m + \finalhyphendemerits\z@pt + \ifdim\parindent=0pt + \leftskip=20pt + \else + \leftskip=\parindent + \fi + \rightskip=\leftskip + \let\ltsfx\ltsftfx + \let\fx\ltsfx + \footnotesize + \endgraf + \centerline{\textbf{Table \thetable\ notes}}% + \endgraf\nobreak\@nobreaktrue + \removelastskip\noindent + \ifcsndefTF{ver@hyperref.sty}{}{% + \let\hyperlink\@secondoftwo + \let\hypertarget\@secondoftwo + }% + \LTS@ltablenoteshook + \endgraf + \endgroup +} +\AfterStartOfDocument{% + \def\LTS@tempa{\ifcsemptyTF\LTS@ltablenoteshook{}\printltablenotes}% + \ifdefTF\longtable{% + \edef\longtable{% + \gdef\noexpand\LTS@ltablenoteshook{}% + \expandcsonce\longtable + }% + \edef\endlongtable{% + \expandcsonce\endlongtable + \expandcsonce\LTS@tempa + }% + }{% + \edef\tabular{% + \gdef\noexpand\LTS@ltablenoteshook{}% + \expandcsonce\tabular + }% + \edef\endtabular{% + \expandcsonce\endtabular + \expandcsonce\LTS@tempa + }% + }% + \ifdefTF\Hy@chapterstring + {\@onelevel@sanitize\Hy@chapterstring}{}% +} + +\new@def*\titleurltext{} +\robust@def*\titleurl#1{% + \ifblankTF{#1}{% + \cpt@err{Empty title url}\@ehc + }% + \def\titleurltext{#1}% + \ifpdfTF{}{% + \def\reserved@a##1/##2/##3/##4\LTS@nil{% + \def\titleurltext{##1/##2/##3/}% + }% + \reserved@a#1///\LTS@nil + }% +} +\robust@def*\LTS@titaurefcnterr#1#2{% + \LTS@err{#1 reference counter too large: > \number#2}\@ehc +} +\robust@def*\LTS@titaureflabel#1#2#3{% + \ifcsndefTF{LTS@titaunote@#2}{% + \ifnum\usename{LTS@titaunote@#2}=#3\relax + \else + \LTS@warn{#1 references may be inconsistent}% + \fi + }{% + \csn@xdef{LTS@titaunote@#2}{#3}% + }% +} +\new@def*\LTS@gettitaunotenr#1{% + \ifcsndefFT{LTS@titaunote@#1}{0}{\usename{LTS@titaunote@#1}}% +} +\new@def*\LTS@savenotes#1#2#3#4{% + \def\LTS@s@venotes##1\sep##2\LTS@nil##3{% + \def\nextnote{##2}% + \edef\reserved@a{% + \let\if\intitle\unexpanded{\intitle\cptswtrue}\else + \unexpanded{\intitle\cptswfalse}\fi + }% + \def\reserved@b{\grightaddtocsn{LTS@#1noteshook}}% + \expandafter\reserved@b\expandafter{% + \reserved@a + \advance\usename{LTS@#1notenr}\@ne + \immediate\write\@auxout{% + \string\LTS@titaureflabel{#1}{##3}{\the\usename{LTS@#1notenr}}% + }% + \def\thefootnote{% + \makebox[1em][l]{% + \if\intitle + \ifcase\usename{LTS@#1notenr}\or#2\or#3\or#4\else + \LTS@titaurefcnterr{Title}{3}\fi + \else + \ifnum\usename{LTS@#1notenr}>20\relax + \LTS@titaurefcnterr{Author}{20}% + \else + \the\usename{LTS@#1notenr}% + \fi + \fi + }% + }% + \footnotetext{##1}% + }% + }% + \AtEndDocument{% + \ifcsndefFT{LTS@#1reftotal}{}{% + \ifnum\usename{LTS@#1reftotal}=\usename{LTS@#1notetotal}\relax + \else + \LTS@err{Number of #1 references not equal to + \MsgBrk number of #1 notes}\@ehc + \fi + }% + }% +} +\cptchardef\LTS@titlereftotal=0 +\cptchardef\LTS@titlenotetotal=0 +\cptchardef\LTS@authorreftotal=0 +\cptchardef\LTS@authornotetotal=0 +\new@def*\LTS@checknotes#1#2#3{% + \ifblankTF{#2}{% + \ifblankTF{#3}{}{% + \LTS@err{Empty #1 references with nonempty #1 notes}\@ehc + }% + }{% + \ifblankTF{#3}{% + \LTS@err{Empty #1 notes with nonempty #1 references}\@ehc + }{}% + }% + \def\LTS@tempb##1##2##3{% + ##3\z@pt + \def\LTS@tempc####1##1####2\LTS@nil{% + \ifblankTF{####2}{% + \advance##3\@ne + }{% + \advance##3\@ne + \LTS@tempc####2\LTS@nil + }% + }% + \LTS@tempc##2##1\LTS@nil + }% + \LTS@tempb,{#2}\@tempcnta + \LTS@tempb\sep{#3}\@tempcntb + \ifnum\@tempcnta=\@tempcntb\else\ltsafterfi + \LTS@err{Number of #1 references doesn't match + \MsgBrk that of #1 notes}\@ehc + \ltsfi + \csnnumadd!{LTS@#1notetotal}\@tempcnta +} +\robust@def*\LTS@gettitaureftotal#1#2{% + \cptelementcount[,]{#2}% + \csnnumadd!{LTS@#1reftotal}\cptelemnr +} +\cptnewvariables{count}[LTS@]{titlenotenr} +% Eg, \titleref{a1,a2} +\robust@def*\titleref#1{% + \LTS@gettitaureftotal{title}{#1}% + \unskip + \textsuperscript{% + \cptfor#1\dofor{% + \ifcase\LTS@gettitaunotenr{##1}\or\ding{'111}% + \or,\ding{'110}\or,\ding{'112}\else + \LTS@titaurefcnterr{Title}{3}\fi\hss + }% + }% +} +% \titlenote[a1,a2]{xxx\sep yyy} +% or \titlenote[a1]{xxx} and \titlenote[a2]{yyy} +\robust@def*\titlenotes{\LTS@testopt\LTS@titlenotes{}} +\newletcs\titlenote\titlenotes +\robust@def*\LTS@titlenotes[#1]#2{% + \ifcsndefTF{ver@pifont.sty}{}{% + \@latex@error{Package 'pifont' not loaded}\@ehc + }% + \begingroup + \LTS@checknotes{title}{#1}{#2}% + \let\intitle\cptswtrue + \LTS@savenotes{title}{\ding{'111}}{\ding{'110}}{\ding{'112}}% + \def\nextnote{#2\sep}% + \cptfor#1\dofor{% + \expandafter\LTS@s@venotes\nextnote\LTS@nil{##1}% + }% + \endgroup +} +\cptnewvariables{count}[LTS@]{authornotenr} +% Eg, \authorref{a1,a2,a3} +\robust@def*\authorref#1{% + \LTS@gettitaureftotal{author}{#1}% + \unskip + \textsuperscript{% + \def\do##1{% + \edef\reserved@a{\LTS@gettitaunotenr{##1}}% + \ifnum\reserved@a>20\relax + \LTS@titaurefcnterr{Author}{20}% + \else + \reserved@a\iflastfox\else,\fi + \fi + \hss + }% + \cfoxloop{#1}\do + }% +} +% Eg, \authornotes[a1,a2]{xxx\sep yyy} +\robust@def*\authornotes{\LTS@testopt\LTS@authornotes{}} +\newletcs\authornote\authornotes +\robust@def*\LTS@authornotes[#1]#2{% + \begingroup + \LTS@checknotes{author}{#1}{#2}% + \cpt@swafalse + \let\intitle\cptswfalse + \LTS@savenotes{author}{}{}{}% + \def\nextnote{#2\sep}% + \cptfor#1\dofor{% + \expandafter\LTS@s@venotes\nextnote\LTS@nil{##1}% + }% + \endgroup +} +% New footnote numbering scheme: +\ltxkeys@definekeys[LTS]{ltsfn}[LTS@]{% + fnmarkwidth/1.4em; + fnmarknrmax/9/ + \ifnum#1>9\relax + \def\LTS@fnmarkwidth{1.5em}% + \else + \ifnum#1>99\relax + \def\LTS@fnmarkwidth{2.5em}% + \fi + \fi; +} +\robust@def*\setfnnrwidth#1{% + \ltxkeys@launchkeys[LTS]{ltsfn}{#1}% +} +\cptnewvariables{count}[LTS@]{fncnta,fncntb} +\LTS@fncnta\@ne +\LTS@fncntb\z@pt +\robust@def*\LTS@fnsymbool#1{% + \begingroup + \let\s\ensuremath + \ifcase#1\or\ding{'110}\or\s\dagger\or\s\ddagger\or + \s\mathsection\or\s\mathparagraph\or\s{||}\or\ding{'111}\or + \ding{'122}\or\ding{'106}\or\ding{'121}\or\ding{'112}\or + \ding{'113}\or\ding{'114}\or\s\bullet\else + \@ctrerr\fi + \endgroup +} +\new@def*\lts@verbatimmatcmdhook{} +\robust@def*\ltsverbatimmatcmds#1{% + \ltsfiltermergecsv[,]\lts@verbatimmatcmdhook{#1}\nofilter +} +\ltsverbatimmatcmds{\iflacus,\dolacus,\then} +\robust@def*\ltsfootnote#1{% + \ifcsndefTF{ver@pifont.sty}{}{% + \@latex@error{Package 'pifont' not loaded}\@ehc + }% + \ifcsndefTF{ver@hyperref.sty}{}{% + \let\hyperlink\@secondoftwo + \let\hypertarget\@secondoftwo + }% + \global\advance\LTS@fncntb\@ne + \ifnum\LTS@fncntb>\LTS@fnmarknrmax\relax + \LTS@fncntb\@ne + \global\advance\LTS@fncnta\@ne + \fi + \unskip + \hyperlink{hy@ltsfn\number\LTS@fncnta\number\LTS@fncntb}{% + \textsuperscript{% + \LTS@fnsymbool{\number\LTS@fncnta}\number\LTS@fncntb + }% + }% + \begingroup + \def\thefootnote{% + \ltsprotectedtokens{\hypertarget}% + {hy@ltsfn\number\LTS@fncnta\number\LTS@fncntb}{% + \hb@xt@\LTS@fnmarkwidth{\LTS@fnsymbool + {\number\LTS@fncnta}\number\LTS@fncntb\hss}% + }% + }% + \cptexpandbracenext\cptletmanytocs\lts@verbatimmatcmdhook\relax + \footnotetext{#1}% + \endgroup +} +%% Creating and listing tags in document. +% \begin{document} +% \ltstags{Physics}% Ignored: no section +% \section{Einstein} +% Double tag entry in the same section takes only one: +% \ltstags{Physics, Mathematics, Physics} +% \section{D. E. Knuth} +% \ltstags{Computer Science, Art, Physics} +% \section{Riemann} +% \ltstags{Mathematics, Art} +% \noprinttags{Computer Science, Literature} +% \ltsprinttags +% \end{document} +\new@def*\lts@taghook{} +\robust@def*\ltstags#1{% + \iflacus#1\dolacus\else + \ifnum\c@section=\z@pt\else + \docommalist{#1}{% + \oifinsetTF{##1}\lts@taghook{% + \def\reserved@a####1##1####2####3\@nil{% + \xifinsetTF{\cptoxdetok{\expandafter{\the\c@section}}}% + {\detokenize{####2}}{}{% + \xdef\lts@taghook{####1;##1{####2{\the\c@section}};####3}% + }% + }% + \expandafter\reserved@a\lts@taghook\@nil + }{% + \xdef\lts@taghook{\cptliststack;\lts@taghook##1{{\the\c@section}}}% + }% + }% + \fi + \fi +} +\def\ltsignoretags#1{% + \cptfiltermergecsv\lts@tagignore{#1}\nofilter +} +\robust@def*\ltsprinttags{% + \ifx\protect\@typeset@protect + \def\csv@do##1{% + \defpass\LTS@tempa####1####{% + \defpass\LTS@tempa########1\@nil{% + \oifinset@sp@TF,{####1}\lts@tagignore{}{% + \def\LTS@tempb{########1}% + \cptnumbersort\LTS@tempb<% + \cptexpandbracenext\lts@formattagsecnos\LTS@tempb + \ltstagnameformat{####1}: % + See section\ifnum\LTS@tempc=\@ne\else s\fi~% + \def\do################1{% + \ifnum\indrisnr>\@ne + \iflastindris\@space and\@space\else,\@space\fi + \fi + ################1% + }% + \indrisloop*\LTS@tempb\do + \ltstagseparator + }% + }% + }% + ##1\@nil + }% + \csv@@parse*[;]\lts@taghook + \else + \@latex@error{Wrong location of '\string\ltsprinttags'}\@ehc + \fi +} +\robust@def*\lts@formattagsecnos#1{% + \begingroup + \@tempcnta\z@pt + \def\LTS@tempb{}% + \def\do##1##2\@nil{% + \ifblankTF{##1}{% + \do##2\@nil + }{% + \advance\@tempcnta\@ne + \edef\LTS@tempb{\cptliststack,\LTS@tempb##1}% + \ifnot@nil{##2}{\do##2\@nil}% + }% + }% + \do#1{\@nil}\@nil + \cptexpanded{\endgroup + \def\noexpand\LTS@tempb{\LTS@tempb}% + \def\noexpand\LTS@tempc{\number\@tempcnta}% + }% +} +\newletcsset{\ltstag=\ltstags,\noprinttags=\ltsignoretags, + \ltstagseparator=\newline,\ltstagnameformat=\textit} + +%% Footnotes at end of paragraphs. +% \begin{ltsparnotes} +% xyz\ltsparnote{This is a paragraph note.} abc. +% \end{ltsparnotes} +\newletcs\ltsparnotesnosep\medbreak +\def\defineparnoteskeys{% + \ltxkeys@declarekeys*[PNT]{parnotes}[lts@pnt]{% + cmd/notecolor/black; + cmd/noteformat/\@firstofone; + cmd/notefont/\footnotesize; + cmd/markformat/\@firstofone; + cmd/vskip/\medskipamount; + cmd/interskip/.5em; + }% +} +\protected\def\declareparnotesformat#1{% + \ifdefTF\PNT@parnotes@notecolor{}\defineparnoteskeys + \ltxkeys@setkeys[PNT]{parnotes}{#1}% +} +\newcommand*\lts@pnthook{} +\newcount\lts@pntcnta +\robust@def*\ltsparnote#1{% + \ifdefTF\PNT@parnotes@notecolor{}{% + \LTS@err{You haven't called the command + \MsgBrk'\string\defineparnoteskeys'}\@ehc + }% + \ifxTF\protect\@typeset@protect{% + \global\advance\lts@pntcnta\@ne + \xdef\lts@pnthook{% + \expandcsonce\lts@pnthook + \begingroup + \noindent + \expandcsonce\lts@pntnotefont + \noexpand\color{\lts@pntnotecolor}% + \expandcsonce\lts@pntmarkformat{% + \noexpand\textsuperscript{\number\lts@pntcnta}% + }% + \expandcsonce\lts@pntnoteformat{\unexpanded{~#1}}% + \noexpand\hspace{\lts@pntinterskip}% + \endgroup + }% + \ifvmode\else\unskip\fi + \lts@pntmarkformat{\textsuperscript{\number\lts@pntcnta}}% + }{}% +} +\protected\def\lts@pntprint{% + \lts@pnthook + \global\lts@pntcnta\z@ + \gdef\lts@pnthook{}% + \lts@pntorigpar + \vspace{\lts@pntvskip}% + \@afterindentfalse\@afterheading +} +\newenvironment{ltsparnotes}{% + \let\lts@pntorigpar\par + \def\par{% + \lts@pntorigpar + \ifxTF\lts@pnthook\@empty{}{% + \vspace{\lts@pntvskip}% + \parskip\z@ + \lts@pntprint + }% + }% +}{% + \ifxTF\lts@pnthook\@empty{}{% + \lts@pntorigpar + \vspace{\lts@pntvskip}% + \parskip\z@ + \lts@pntprint + }% + \lts@pntorigpar + % \par returns to its default definition outside the 'parnotes' + % environment. + \@ignoretrue +} +%% Define counters that have the property that they're printed only +% when/if they're called more than once in a run. +% Eg, +% \DefineDiscCounterKeys +% \DefineDiscCounters[numbertype=\arabic]{counterone,countertwo} +% \begin{document} +% \begin{enumerate} +% \item \showcounterone \showcounterone \showcounterone \resetcounterone +% \item \showcounterone[numbertype=\arabic] +% \showcounterone[numbertype=\alph]\showcounterone[numbertype=\Alph]% +% \resetcounterone +% \item \showcounterone \resetcounterone +% \end{enumerate} +\def\DefineDiscCounterKeys{% + \ltxkeys@declarekeys*[DC]{disccount}[disc@]{% + cmd/format/\@firstofone; + cmd/numbertype/\arabic/ + \ifescapedTF{##1}{% + \xifinsetTF{,\detokenize{##1},}{% + ,\detokenize{\arabic,\alph,\Alph},% + }{}{% + \@latex@error{Invalid number type '\detokenize{##1}'}\@ehc + }% + }{% + \@latex@error{Number type '\detokenize{##1}' must be escaped}\@ehc + }; + }% +} +\newcounter{disccounter@aux} +\AtBeginDocument{% + \ifdefTF\disccounter@hook{}{\def\disccounter@hook{}}% +} +\newcommand*\discc@unter@aux{\the\numexpr\thedisccounter@aux-20000\relax} +\robust@def*\DefineDiscCounters{\cpt@testopt\disc@definecounters{}} +\robust@def*\disc@definecounters[#1]#2{% + \ifdefTF\DC@disccount@format{}{% + \LTS@err{You haven't called the command + \MsgBrk'\string\DefineDiscCounterKeys'}\@ehc + }% + \cptexpandargonce{\ltxkeys@setkeys[DC]{disccount}}{#1}% + \setcounter{disccounter@aux}{0}% + \docommalist{#2}{% + \newcounter{##1}% + \expandafter\newcommand\csname show##1\endcsname[1][]{% + \stepcounter{##1}% + \stepcounter{disccounter@aux}% + \cptexpandargonce{\ltxkeys@setkeys[DC]{disccount}}{####1}% + \xifinsetTF{,##1@reset@\discc@unter@aux,}% + {,\disccounter@hook,}{}{\disc@format{\disc@numbertype{##1}}}% + }% + \csn@def{reset##1}{% + \ifnum\csname c@##1\endcsname=\@ne + \xifinsetTF{,##1@reset@\discc@unter@aux,}{,\disccounter@hook,}{}{% + \xdef\disccounter@hook{% + \ifcsemptyTF\disccounter@hook{}{\disccounter@hook,}% + ##1@reset@\discc@unter@aux + }% + }% + \fi + \setcounter{##1}{0}% + }% + }% +} +\AtEndDocument{% + \if@filesw + \immediate\write\@auxout{% + \gdef\string\disccounter@hook{\disccounter@hook}% + }% + \else + \@latex@warning@no@line{File '\jobname.aux' not open}% + \fi +} +\newcommand*\discbraced[1]{{\tt\string{#1\string}}} +\robust@def*\ltsgarbagetext{\cpt@testopt\lts@garbagetext{5}} +\robust@def*\lts@garbagetext[#1]{% + \begingroup + \chardef\nr1 + \loop + \noindent Some sample text here. Some more sample text. + And more sample text. + \pushnumber\nr + \ifnum\nr<#1\relax + \repeat + \endgroup +} + +\endinput |