# Algorithms disappear when I use multicols

This is my code:

\documentclass[11pt]{llncs}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{dsfont}
\usepackage{multicol}
\usepackage{fixltx2e}
\usepackage{multicol}
\newcommand\blfootnote[1]{%
\begingroup
\renewcommand\thefootnote{}\footnote{#1}%
\endgroup
}
\usepackage[T1]{fontenc}
\usepackage{comment}
\usepackage{amsmath}
\setcounter{MaxMatrixCols}{20}
\usepackage[margin=1in]{geometry}
\usepackage[boxruled, linesnumbered]{algorithm2e}
\usepackage{xcolor}
\usepackage{setspace}
\usepackage{hyperref}
\definecolor{bl}{rgb}{0.0,0.2,0.6}
\definecolor{dark-red}{rgb}{0.4,0.15,0.15}
\definecolor{dark-blue}{rgb}{0.15,0.15,0.4}
\definecolor{medium-blue}{rgb}{0,0,0.5}
\usepackage{sectsty}
\hypersetup{
citecolor={dark-blue}, urlcolor={medium-blue}
}
\usepackage{graphicx}
\usepackage[compact]{titlesec}
\begin{document}
\begin{multicols}{2}
\begin{algorithm}[!h]
\SetAlgoLined
\KwData{\textsc{Something} $S$, \textsc{Another thing} $A$}
do something with $S$\;
do another thing with $A$\;
\end{algorithm}
\columnbreak
\begin{algorithm}[!h]
\label{alg:cbl}
\SetAlgoLined
\KwData{\textsc{Something} $S$, \textsc{Another thing} $A$}
do something with $S$\;
do another thing with $A$\;
\end{algorithm}
\end{multicols}
\end{document}


The page appears blank.

When I remove \begin{multicols}...\end{multicols}, the page returns to normal.

What I'm trying to do is to display those very short two algorithms side by side. What shall I do?

The multicol package complains in the .log:

Package multicol Warning: Floats and marginpars not allowed inside multicols' environment!.

This happens even though you think you're forcing a placement here in the text, which seems like things shouldn't float. However, as is discussed in How to influence the position of float environments like figure and table in LaTeX?, placing a float here doesn't always have the expected output nor does it change it's floating status.

algorithm2e provides a forced, non-float Here placement though, which provides the desired output:

\documentclass{article}
\usepackage{multicol}
\usepackage[margin=1in]{geometry}
\usepackage[boxruled, linesnumbered]{algorithm2e}
\begin{document}
\begin{multicols}{2}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{\textsc{Something} $S$, \textsc{Another thing} $A$}
do something with $S$\;
do another thing with $A$\;
\end{algorithm}

\columnbreak

\begin{algorithm}[H]
\label{alg:cbl}
\SetAlgoLined
\KwData{\textsc{Something} $S$, \textsc{Another thing} $A$}
do something with $S$\;
do another thing with $A$\;
\end{algorithm}
\end{multicols}
\end{document}


If you're only after a side-by-side setting of two algorithms, then you can just set them using separate minipages:

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage[boxruled, linesnumbered]{algorithm2e}
\begin{document}
\noindent
\begin{minipage}{\dimexpr.5\textwidth-.5\columnsep}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{\textsc{Something} $S$, \textsc{Another thing} $A$}
do something with $S$\;
do another thing with $A$\;
\end{algorithm}
\end{minipage}\hfill%
\begin{minipage}{\dimexpr.5\textwidth-.5\columnsep}
\begin{algorithm}[H]
\label{alg:cbl}
\SetAlgoLined
\KwData{\textsc{Something} $S$, \textsc{Another thing} $A$}
do something with $S$\;
do another thing with $A$\;
\end{algorithm}%
\end{minipage}
\end{document}


The above minipages are made to fit the original columns with a gap between them equalling \columnsep`.