]> mj.ucw.cz Git - ucwmac.git/commitdiff
ucw-algo: Comments
authorMartin Mares <mj@ucw.cz>
Tue, 5 Jun 2018 21:01:29 +0000 (23:01 +0200)
committerMartin Mares <mj@ucw.cz>
Tue, 5 Jun 2018 21:01:29 +0000 (23:01 +0200)
test.tex
ucw-algo.tex

index 5d2ba496422fb9c801fcfbee24d36dafffe80c31..42ffd775b416c83b312e2a8396c718047949eaba 100644 (file)
--- a/test.tex
+++ b/test.tex
@@ -106,7 +106,7 @@ The set{\settextsize{11}text}size macro does not strew spaces.
 
 \algo{Factorial}\algalias{calculate a~factorial}
 \algin A~non-negative integer~$n$
-\:If $n\ge 1$:
+\:If $n\ge 1$:  \cmt{Test if something}
 \::Return $n$
 \:Else:
 \::Return $n \cdot \alg{Factorial}(n-1)$
index cb65f042bdcf0b74d74f59e210d4dbc168277705..e356ef4f6f3f47ac42f697b1a89a916f36bfd82f 100644 (file)
@@ -7,7 +7,7 @@
 %      \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
@@ -59,6 +59,7 @@
        \inititemize
        \let\:=\algoitem
        \def\={\leftarrow}
+       \let\cmt=\algcmt
        \itemcount=0
 }
 
@@ -88,3 +89,7 @@
 
 % 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}}