Algorithm Extension

The algorithm extension provides a means to display pseudo-code similar to the latex algorithmicx package. Algorithms are similar to tables in that users can assign captions, ids, and provide shortcuts to the algorithm.

Configuration options for the algorithm extension.

KeyDefaultDescription
activeTrueToggle for disabling the extension. This only changes the initial active state, use setActive to control at runtime.
prefixAlgorithmThe caption prefix (e.g., Alg.).

The Algorithm Float

Example of assigning a caption and id

!algorithm caption=Test id=algotest
[!function!begin name=testFunction]
[!function!end]

Look at [!ref](algotest)

Configuration options for the algorithm command.

KeyDefaultDescription
styleNoneThe style settings that are passed to rendered HTML tag.
classNoneThe class settings to be passed to rendered HTML tag.
idNoneThe class settings to be passed to the rendered tag.
captionNoneThe caption text for the float object.
prefixNoneThe numbered caption label to include prior to the caption text.

Line Commands

The algorithm command by itself is not very informative. Users should use the following line commands following the algorithm float definition. Below is an example using some of the commands described in the following sections. \quad

!algorithm caption=The Bellman-Kalaba algorithm id=bk
[!function!begin name=BellmanKalab param=$G$, $u$, $l$, $p$]
[!for!begin condition=$v\in V(G)$]
[!state text=$l(v) \leftarrow \infty$]
[!for!end]
[!state text=$l(u) \leftarrow 0$]
[!while!begin condition=$changed$ comment=Initial is $changed \leftarrow \text{True}$]
[!for!begin condition=$i \leftarrow 1, n$]
[!state text=$min \leftarrow l(v_i)$]
[!for!begin condition=$j \leftarrow 1, n$]
[!ifthen!if condition=$min > e(v_i, v_j) + l(v_j)$]
[!state text=$min \leftarrow e(v_i, v_j) + l(v_j)$]
[!state text=$p(i) \leftarrow v_j$]
[!ifthen!end]
[!for!end]
[!state text=$l’(i) \leftarrow min$]
[!for!end]
[!state text=$changed \leftarrow l \not= l’$]
[!state text=$l \leftarrow l’$]
[!while!end]
[!function!end]

Function Commands

Example of using function line commands

!algorithm
[!function!begin name=<function name> param=parameters]
<content>
[!function!end]
[!procedure!begin name=<procedure name> param=parameters]
<content>
[!procedure!end]

Configuration options for the algorithm command.

KeyDefaultDescription
styleNoneThe style settings that are passed to rendered HTML tag.
classNoneThe class settings to be passed to rendered HTML tag.
idNoneThe class settings to be passed to the rendered tag.
commentNoneComment placed to right of algorithm component.
nameNoneFunction name
paramNoneFunction parameters

Loop Commands

Example of using loop line commands

!algorithm
[!while!begin condition=<condition>]
<content>
[!while!end]
[!for!begin condition=<condition>]
<content>
[!for!end]

Configuration options for the algorithm command.

KeyDefaultDescription
styleNoneThe style settings that are passed to rendered HTML tag.
classNoneThe class settings to be passed to rendered HTML tag.
idNoneThe class settings to be passed to the rendered tag.
commentNoneComment placed to right of algorithm component.
conditionLoop condition

If-Then Commands

Example of using if-then line commands

!algorithm
[!ifthen!if condition=<condition>]
<content>
[!ifthen!elif condition=<condition>]
<content>
[!ifthen!else]
<content>
[!ifthen!end]

Configuration options for the algorithm command.

KeyDefaultDescription
styleNoneThe style settings that are passed to rendered HTML tag.
classNoneThe class settings to be passed to rendered HTML tag.
idNoneThe class settings to be passed to the rendered tag.
commentNoneComment placed to right of algorithm component.
conditionIf and if else condition

Statement Command

Example of using statement line commands

!algorithm
[!state text=<text>]

Configuration options for the algorithm command.

KeyDefaultDescription
styleNoneThe style settings that are passed to rendered HTML tag.
classNoneThe class settings to be passed to rendered HTML tag.
idNoneThe class settings to be passed to the rendered tag.
commentNoneComment placed to right of algorithm component.
textStatement text