]> mj.ucw.cz Git - ucwmac.git/blobdiff - ucw-algo.tex
ucw-ref: Fixed bug in \pageid
[ucwmac.git] / ucw-algo.tex
index cb65f042bdcf0b74d74f59e210d4dbc168277705..3d76de07ce80dc1cec769803981a285a20a19c72 100644 (file)
@@ -7,17 +7,18 @@
 %      \algo{name of the algorithm}\algalias{a longer name}
 %      \algin input description
 %      \:step
-%      \:step
+%      \:step  \cmt{comment}
 %      \::[identifier]nested step
 %      \:::yet more nested step
 %      \algout output description
 %      \endalgo
 
 % Localized strings
-\localedef{en}{alg:alg}{Algorithm}
-\localedef{en}{alg:proc}{Procedure}
-\localedef{en}{alg:in}{Input}
-\localedef{en}{alg:out}{Output}
+\localedef{0}{alg:alg}{Algorithm}
+\localedef{0}{alg:proc}{Procedure}
+\localedef{0}{alg:func}{Function}
+\localedef{0}{alg:in}{Input}
+\localedef{0}{alg:out}{Output}
 
 % Item indent
 \newdimen\algoindent
 \def\algostep#1{\hbox to \algolabelwidth{\hss #1~~}}
 
 \def\algoinit{
-       \goodbreak
        \begingroup
        \algospacing
        \inititemize
        \let\:=\algoitem
        \def\={\leftarrow}
+       \let\cmt=\algcmt
        \itemcount=0
 }
 
 \def\typedalgo#1#2{\algoinit {\bo #1\/} \alg{#2}}
 \def\algo#1{\typedalgo{\localestr{alg:alg}}{#1}}
 \def\proc#1{\typedalgo{\localestr{alg:proc}}{#1}}
+\def\func#1{\typedalgo{\localestr{alg:func}}{#1}}
 \def\headlessalgo{\algoinit}
 
-\def\endalgo{\goodbreak\endlist\endgroup}
+\def\endalgo{\endlist\endgroup}
 \let\endproc=\endalgo
 
 \def\algoitem{%
 \optdef\algoitemgo{\ifx\addid\undefined\else\addid{item}{\the\itemcount}\fi}
 
 \def\algin{\par\nobreak{\it \localestr{alg:in}:\/} }
-\def\algout{\par\nobreak\parindent=0pt{\it \localestr{alg:in}:\/} }
-\def\alginbreak{\hfil\break\hphantom{\it \localestr{alg:out}:\/} }
+\def\algout{\par\nobreak\parindent=0pt{\it \localestr{alg:out}:\/} }
+\def\alginbreak{\hfil\break\hphantom{\it \localestr{alg:in}:\/} }
 \def\algalias#1{ (#1)}
 
 % Algorithm name in text or in a formula
 \protected\def\alg#1{\leavevmode\hbox{\csc #1}}
+
+% Comments
+\def\algcmt#1{\unskip~~\hfill\fullcmt{#1}\ignorespaces}
+\def\fullcmt#1{{$\triangleleft$\hskip0.5em\it #1}}