diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/computational-complexity/ccalgo.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/computational-complexity/ccalgo.sty | 165 |
1 files changed, 121 insertions, 44 deletions
diff --git a/Master/texmf-dist/tex/latex/computational-complexity/ccalgo.sty b/Master/texmf-dist/tex/latex/computational-complexity/ccalgo.sty index 432507a3513..6912029eb6e 100644 --- a/Master/texmf-dist/tex/latex/computational-complexity/ccalgo.sty +++ b/Master/texmf-dist/tex/latex/computational-complexity/ccalgo.sty @@ -34,7 +34,6 @@ \NeedsTeXFormat{LaTeX2e}[1995/12/01] \ProvidesPackage{ccalgo}[2005/08/27 v2.05 algorithm environment for cc. Michael Nuesken, Bonn.] -\RequirePackage{ccaux} \let\namedalgorithm\@undefined \let\endnamedalgorithm\@undefined \let\algorithm\@undefined @@ -106,6 +105,7 @@ Command \protect\@item\space has changed.\MessageBreak Check if current package is valid} \fi} +\RequirePackage{ccaux} \RequirePackage{theorem} \RequirePackage{thcc} \RequirePackage{relabel} @@ -147,69 +147,127 @@ \newcommand{\labelalgonumerate}{% \count@\value{algonumerate}% \ifnum\count@<\z@ - \algonumfield:% + \algonumfield% \else - \makealgolabel{\thealgonumerate}\fi + \makealgolabel{\thealgonumerate}% + \fi }% \newdimen\algo@labelsep \newdimen\steplabelwidth \newtoks\AtNextItem \newif\if@requireditemscomplete +\newif\if@noitemargcopy +\let\orig@item\item +\def\item{\@ifnextchar[{\@noitemargcopyfalse\orig@item}{\@noitemargcopytrue\orig@item}} +\newcount\last@algolabeltype +\newcount\this@algolabeltype \newcommand{\algonumerate@label}[1]{% - \def\@tempa{#1}\def\@tempc{\@itemlabel}% - %%\show\@tempa\show\@tempc - \ifx\@tempa\@tempc\global\@speciallabelfalse - \else\global\@speciallabeltrue\fi - \expandafter\ifnum\value{algonumerate}<\z@ - #1\hskip\algo@labelsep% - \else - \ifx\@tempa\@empty - \hskip\steplabelwidth\hskip\algo@labelsep + \expandafter\count@\value{algonumerate}% + \if@noitemargcopy + \ifnum\count@<\z@ + \let\next\algonumerate@labelautomatic + \global\last@algolabeltype\this@algolabeltype + \global\this@algolabeltype\m@ne + \else + \let\next\algonumerate@labelnumber + \global\last@algolabeltype\this@algolabeltype + \global\this@algolabeltype\@ne + \fi \else + \def\@tempa{#1}% + \ifx\@tempa\@empty + \let\next\algonumerate@labelempty + \global\last@algolabeltype\this@algolabeltype + \global\this@algolabeltype\tw@ + \else + \global\last@algolabeltype\this@algolabeltype + \global\this@algolabeltype\z@ + \let\next\algonumerate@labelexplicit + \fi + \fi\next{#1}} +\newcommand{\algonumerate@makelabelexplicit}[1]{% + #1:\hskip\algo@labelsep% +} +\newcommand{\algonumerate@makelabelempty}[1]{% + \hskip\steplabelwidth\hskip\algo@labelsep% +} +\newcommand{\algonumerate@makelabelautomatic}[1]{% + #1:\hskip\algo@labelsep% +} +\newcommand{\algonumerate@makelabelnumber}[1]{% \hb@xt@\steplabelwidth{\hss - \hb@xt@\steplabelwidth{\hfill - \if@speciallabel - \makeoptalgolabel{#1}% - \else + %\hb@xt@\steplabelwidth{\hfill #1% - \fi - }}\hskip\algo@labelsep% - \fi\fi - \global\let\algonumerate@global\global - \gdef\global{\algonumerate@global\let\global\algonumerate@global + %} + }\hskip\algo@labelsep% +} +\newcommand{\algonumerate@postprocess}[1]{% \expandafter\count@\value{algonumerate}% %%{\tracingall\nonstopmode\showbox\@tempboxa}% - \ifnum\count@=\m@ne - \stepcounter{algonumerate}% - \fi - \ifnum\count@=\z@ - \if@requireditemscomplete\else - \global\@requireditemscompletetrue - \ifnum\algonumerate@items>\z@\medskip\fi - \fi - \fi - \ifnum\count@=\@ne - \if@requireditemscomplete\else - \global\@requireditemscompletetrue - \ifnum\algonumerate@items>\z@\medskip\fi - \fi + \ifnum\last@algolabeltype<\@ne + \ifnum\this@algolabeltype=\@ne + \medskip \fi - \if@speciallabel - \protected@edef\@currentlabel{\csname p@\@listctr\endcsname - {\makeoptalgocurrentlabel{#1}}}% - \protected@edef\@bare@currentlabel{#1}% \fi + #1% \global\let\latest@item@currentlabel\@currentlabel \global\let\latest@item@bare@currentlabel\@bare@currentlabel + \ifnum\count@=\m@ne + \stepcounter{algonumerate}% + \fi \global\@speciallabeltrue \the\AtNextItem \global\AtNextItem{}% \reinit@list@label +} +\newcommand{\algonumerate@labelexplicit}[1]{% For algorithm i/o + \typeout{item explicit [#1]}% + \algonumerate@makelabelexplicit{#1}% + \global\let\algonumerate@global\global + \gdef\global{\algonumerate@global\let\global\algonumerate@global + \algonumerate@postprocess{% + \protected@edef\@currentlabel{\csname p@\@listctr\endcsname + {\makeoptalgocurrentlabel{#1}}}% + \protected@edef\@bare@currentlabel{#1}% + }% \global}% - } +} +\newcommand{\algonumerate@labelempty}[1]{% For algorithm i/o + \typeout{item empty [#1]}% + \algonumerate@makelabelempty{}% + \global\let\algonumerate@global\global + \gdef\global{\algonumerate@global\let\global\algonumerate@global + \algonumerate@postprocess{}% + \global}% +} +\newcommand{\algonumerate@labelautomatic}[1]{% For algorithm steps + \typeout{item automatic [#1]}% + \algonumerate@makelabelautomatic{#1}% + \global\let\algonumerate@global\global + \gdef\global{\algonumerate@global\let\global\algonumerate@global + \algonumerate@postprocess{% + \protected@edef\@currentlabel{\csname p@\@listctr\endcsname + {\makeoptalgocurrentlabel{#1}}}% + \protected@edef\@bare@currentlabel{#1}% + }% + \global}% +} +\newcommand{\algonumerate@labelnumber}[1]{% For algorithm steps + \typeout{item numbered [#1]}% + \algonumerate@makelabelnumber{#1}% + \global\let\algonumerate@global\global + \gdef\global{\algonumerate@global\let\global\algonumerate@global + \algonumerate@postprocess{}% + \global}% +} +%%% \newdimen\algonumerate@maxindent +\newdimen\@algolongestlabel \AtBeginDocument{\ifdim\algonumerate@maxindent=\z@ \algonumerate@maxindent.2\textwidth\fi} \def\algonumerateinit#1{% + \setcounter{algonumerate}{-1}% + \this@algolabeltype=\@M + \@algolongestlabel\z@ \def\@algonumfield{}% \let\ccorg@or\or\let\or\relax \algonumerate@items\z@ @@ -218,6 +276,9 @@ \@temptokena\expandafter{\@tempa}% \toks@\expandafter{\@algonumfield}% \edef\@algonumfield{\the\@temptokena\or\the\toks@}% + \setbox\@tempboxa\hbox{\algonumerate@makelabelautomatic{\the\toks@}}% + \ifdim\wd\@tempboxa>\@algolongestlabel\relax + \@algolongestlabel\wd\@tempboxa\fi }% \let\or\ccorg@or \toks@\expandafter{\@algonumfield}% @@ -261,6 +322,7 @@ \let\endbody\endalgo@block \let\meta\algo@meta \let\endmeta\endalgo@meta + \def\skipremainingspecialitems{\setcounter{algonumerate}{0}}% }{% \endlist\vskip\topskip} \newdimen\blockindent \blockindent\parindent @@ -390,8 +452,10 @@ \theoremstyle{ccalgo} \newtheorem{named@lg@r@thm}{\the\algotitle} \defprefix{named@lg@r@thm}#1{\the\algotitle~#1} +\ifx\c@namedth@@r@m\@undefined\else \let\c@named@lg@r@thm\c@namedth@@r@m \let\thenamed@lg@r@thm\thenamedth@@r@m +\fi \babel\def\babelInput{Input}[german=Eingabe,french=Entr\'ee] \babel\def\babelOutput{Output}[german=Ausgabe,french=Sortie] \babel\def\babelstep{step}[german=Schritt,french=pas]%% ??? pas? @@ -408,12 +472,24 @@ \algotitle{#1}% \n@medalgorithm} {\endalgonumerate\csname end\algo@theorem\endcsname} -\newcommand{\n@medalgorithm}[2][\babelInput,\protect\babelOutput]{% +\newcommand{\n@medalgorithm}[1][\babelInput,\protect\babelOutput]{% \algonumerateinit{#1}% - \algorithmmasterkey{#2}% + \n@m@d@lgorithmgetlongestlabel} +\newcommand{\n@m@d@lgorithmgetlongestlabel}[1][]{% + \def\@tempa{#1}% + \ifx\@tempa\@empty\else + \setbox\@tempboxa\hbox{\algonumerate@makelabel{#1}}% + \ifdim\wd\@tempboxa>\@algolongestlabel\relax + \@algolongestlabel\wd\@tempboxa\fi + \fi + \n@m@d@lgorithmgetmasterkey +} +\newcommand{\n@m@d@lgorithmgetmasterkey}[1]{% + \algorithmmasterkey{#1}% \edef\@tempa{\the\algorithmmasterkey}\ifx\@tempa\@empty \PackageError{ccalgo}{Empty key for algorithm like environment}{}\fi% - \n@m@d@lgorithm} + \n@m@d@lgorithm +} \newcommand{\n@m@d@lgorithm}[1][]{% \def\@tempa{#1}% \ifx\@tempa\@empty\csname\algo@theorem\endcsname @@ -461,7 +537,8 @@ \babel\def\endIF{}[]% \babel\def\CALL{\keyword{Call}}[german=\keyword{Rufe}]% \babel\def\RETURN{\keyword{Return}}[german=\keyword{Antworte}]% - \expandafter\selectlanguage\expandafter{\languagename} + \def\@tempa{nohyphenation}\ifx\languagename\@tempa\else% + \expandafter\selectlanguage\expandafter{\languagename}\fi% \def\COMMENT##1{$\{$ ##1 $\}$}% } \newcommand{\optitem}[1]{% |