How can I use switch cases in algorithmicx
? For example a code like this:
switch s do
--case a
----assert(1)
--case b
----assert(0)
etc.
Is is possible to define it as a command?
algorithmicxalgorithms
How can I use switch cases in algorithmicx
? For example a code like this:
switch s do
--case a
----assert(1)
--case b
----assert(0)
etc.
Is is possible to define it as a command?
Best Answer
Use the following:
Both new "environments"
\Switch
...\EndSwitch
and\Case
...\EndCase
are defined to have beginning and ending text. However, using\algnotext*{<env>}
removes any typesetting of that command, effectively removing the ending command for both\Switch
and\Case
. It's still needed, since there may be more than one entry so its not possible to generalise with some number-of-lines-termination.