Is there any elegent way to place algorithm without using algorithm
environment?
[Tex/LaTex] How to place algorithm outside float
algorithmsfloats
algorithmsfloats
Is there any elegent way to place algorithm without using algorithm
environment?
Best Answer
You don't have to put it in a float. But it depends on what you're after. If the intent is to avoid the
algorithm
float yet still have captions, then thecaption
package provides\captionof{<float type>}{<caption>}
that allows you to set a caption of a float outside a float. For example:While
algorithm
provides the floatingalgorithm
environment, it's only used for thealgorithm
counter and float type. The above works foralgorithmic
and/oralgorithmicx
.It is advisable to contain the algorithm inside a box (like a
minipage
), but this may depend on the setting of the algorithm in the code itself. For example,algorithmicx
sets its algorithms (in thealgorithmic
environment) as a list, which will break across the page boundary. If you don't want it, contain it.algorithm2e
provides its own "do not float"[H]
float specifier, setting the contents in aminipage
if used this way. So one would have to useunder those conditions. A large amount of leg-work is done by the package at the start of the
algorithm
environment in order to set things up since it has its own interface (using\;
to denote line-ends, otherwise known as a horizontal space in math-mode outside the environment).