I'm writing an algorithm box using algorithm2e
and want to align the input arguments in a grid. I got close to the desired layout using two tabular
environments, each inside of a minipage
.
However, I would like both the word "Input:" and the two tables to align at the top instead of being vertically centered. Moreover, I would like to reduce the column and row spacing but putting \setlength{\tabcolsep}{.5em}%
and \renewcommand{\arraystretch}{1.5}%
inside the table does not have any effect. How can this be done?
\usepackage[linesnumbered,ruled,noend]{algorithm2e}
\begin{algorithm}[h!]
\SetEndCharOfAlgoLine{}
\SetKwInOut{Input}{Input}
\Input{
\begin{minipage}{0.4\textwidth}
\begin{tabular}{ll}
$A$ & Description \\
$B$ & Description \\
$C$ & Description \\
$D$ & Description \\
\end{tabular}
\end{minipage}\hfill
\begin{minipage}{0.4\textwidth}
\begin{tabular}{ll}
$E$ & Description \\
$F$ & Description \\
$G$ & Description \\
\end{tabular}
\end{minipage}\hfill
}
\BlankLine
Initialize variables.
\For{all steps}{
\Comment{Do something.}
}
\Return{The result.}
\BlankLine
\caption{Algorithm caption.}
\end{algorithm}