Algorithm Extension
The algorithm extension provides a means to display psuedo-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.
Key | Default | Description |
---|---|---|
active | True | Toggle for disabling the extension. This only changes the initial active state, use setActive to control at runtime. |
prefix | Algorithm | The 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)
Algorithm 2: Test
Look at Algorithm 2
Configuration options for the algorithm command.
Key | Default | Description |
---|---|---|
style | None | The style settings that are passed to rendered HTML tag. |
class | None | The class settings to be passed to rendered HTML tag. |
id | None | The class settings to be passed to the rendered tag. |
caption | None | The caption text for the float object. |
prefix | None | The 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.
!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=Intial 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]
Algorithm 1: The Bellman-Kalaba algorithm
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.
Key | Default | Description |
---|---|---|
style | None | The style settings that are passed to rendered HTML tag. |
class | None | The class settings to be passed to rendered HTML tag. |
id | None | The class settings to be passed to the rendered tag. |
comment | None | Comment placed to right of algorithm component. |
name | None | Function name |
param | None | Function parameters |
Loop Commands
Configuration options for the algorithm command.
Key | Default | Description |
---|---|---|
style | None | The style settings that are passed to rendered HTML tag. |
class | None | The class settings to be passed to rendered HTML tag. |
id | None | The class settings to be passed to the rendered tag. |
comment | None | Comment placed to right of algorithm component. |
condition | Loop condition |
If-Then Commands
Configuration options for the algorithm command.
Key | Default | Description |
---|---|---|
style | None | The style settings that are passed to rendered HTML tag. |
class | None | The class settings to be passed to rendered HTML tag. |
id | None | The class settings to be passed to the rendered tag. |
comment | None | Comment placed to right of algorithm component. |
condition | If and if else condition |
Statement Command
Configuration options for the algorithm command.
Key | Default | Description |
---|---|---|
style | None | The style settings that are passed to rendered HTML tag. |
class | None | The class settings to be passed to rendered HTML tag. |
id | None | The class settings to be passed to the rendered tag. |
comment | None | Comment placed to right of algorithm component. |
text | Statement text |