I have two algorithms in a latex document using a class document of one column. The first algorithm take almost one page, and the second one is on the next page. Is there ant way to format this to gain some place in the document. Maybe putting the two algorithms on the same pages (I don't know if it is possible).
I use \usepackage{algorithm}
and \usepackage{algpseudocode}
. This is an example of the two algorithms (actually they are longer than this, this is just an example).
\begin{algorithm}
\caption{My First Algorithm (param)}
\label{algo1}
\begin{algorithmic}[1]
\State $A = A + param$
\State $\alpha = 34$
\State etc ...
\end{algorithmic}
\end{algorithm}
\begin{algorithm}
\caption{My Second Algorithm (A)}
\label{algo1}
\begin{algorithmic}[1]
\State $C = C + A$
\State $\alpha = \beta$
\State etc ...
\end{algorithmic}
\end{algorithm}
Best Answer
This a a slight modification of How to put algorithm and figure(s) side by side?
Here is a minimal example showing how to pair algorithms side-by-side:
The idea behind this approach is to have two
minipage
s spanning the entire\linewidth
. Theseminipage
s then house the non-floatingalgorithmic
environments, as well as the non-floating\captionof
caption. If need be, you can wrap the entire doubleminipage
inside a floatingalgorithm
environment.The use of
geometry
was just to gain some stock real estate (may not be required in your instance), whilelipsum
provided some dummy text, Lorem ipsum style.caption
provides the means to have a caption outside of a float via\captionof
. However, it requires thecompatibility=false
option to work, sincellncs
already redefines\caption
- detected bycaption
.algorithm
is still required, since it provides thealgorithm
counter and "List of Algorithms" capability.