You can combine any number of algorithmic
environments within your algorithm
environment. The following MWE shows how you can do this to create a section called Inputs and one called Steps while still being able to break the algorithm over more than one page (with \algstore
and \algrestore
).
\documentclass{article}
\usepackage{algorithm}% http://ctan.org/pkg/algorithm
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx
\usepackage{caption}% http://ctan.org/pkg/caption
\begin{document}
\begin{algorithm}
\caption{My algorithm}
\textbf{Inputs}% Inputs section
\begin{algorithmic}[1]
\State Input $A$
\State Input $B$
\State Input $C$
\end{algorithmic}
\bigskip
\textbf{Steps}% Steps section
\begin{algorithmic}[1]
\Procedure{Euclid}{$a,b$}\Comment{The g.c.d. of a and b}
\State $r\gets a\bmod b$
\While{$r\not=0$}\Comment{We have the answer if r is 0}
\State $a\gets b$
\State $b\gets r$
\algstore{myalg}
\end{algorithmic}
\end{algorithm}
\clearpage
\begin{algorithm}
\ContinuedFloat
\caption{My algorithm (continued)}
\begin{algorithmic}
\algrestore{myalg}
\State $r\gets a\bmod b$
\EndWhile\label{euclidendwhile}
\State \textbf{return} $b$\Comment{The gcd is b}
\EndProcedure
\end{algorithmic}
\end{algorithm}
\end{document}
If you're not concerned about page breaking, I'd just set this in a tabularx
. It's all about the column specification:
\documentclass{article}
\usepackage{tabularx}% Loads the array package
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{
@{\hspace{1.5em}}% Space for left bullet
>{\leavevmode\llap{\textbullet~}\raggedright}% Left bullet + formatting of column
X% Left column specification
@{\quad\hspace{1.5em}}% Space between columns + right bullet space
>{\leavevmode\llap{\textbullet~}\raggedright\arraybackslash}% Right bullet + formatting of column
X% Right column specification
@{}% No column space on right
}
Mary had a little lamb, &
Her fleece was white as snow. And everywhere that Mary went, the lamb was sure to go. \\
Old MacDonald had a farm, &
E-I-E-I-O! And on this farm he had a cow, E-I-E-I-O! With a moo moo here, and a moo moo there.
\end{tabularx}
\end{document}
As mentioned, the column specification is the important thing here. Technically we only have 2 X
-columns, each of which have a space of 1.5em
on the left of it that is used to place a \textbullet
inside. The look is similar to that of an itemize
. The two columns have an additional \quad
between them.
With the correct setup, the code for your construction should be fairly easy to read/interpret, and therefore be easily maintained.
Content can also be stretched vertically by adjusting \arraystretch
accordingly. Headings and other tabular
-related constructions are also easy to add, for example, the use of booktabs
:
\documentclass{article}
\usepackage{tabularx,booktabs}
\newcommand{\fakeleft}{\multicolumn{1}{X}{}}
\let\fakeright\fakeleft
\begin{document}
\renewcommand{\arraystretch}{1.5}% Vertically stretch tabular constructions
\noindent
\begin{tabularx}{\textwidth}{
@{\hspace{1.5em}}% Space for left bullet
>{\leavevmode\llap{\textbullet~}\raggedright}% Left bullet + formatting of column
X% Left column specification
@{\quad\hspace{1.5em}}% Space between columns + right bullet space
>{\leavevmode\llap{\textbullet~}\raggedright\arraybackslash}% Right bullet + formatting of column
X% Right column specification
@{}% No column space on right
}
\toprule
\multicolumn{1}{X}{\centering\bfseries Left heading} &
\multicolumn{1}{X}{\centering\bfseries Right heading} \\
\midrule
Mary had a little lamb, &
Her fleece was white as snow. And everywhere that Mary went, the lamb was sure to go. \\
\fakeleft &
This is a right bullet without a left counterpart. \\
Old MacDonald had a farm, &
E-I-E-I-O! And on this farm he had a cow, E-I-E-I-O! With a moo moo here, and a moo moo there. \\
\bottomrule
\end{tabularx}
\end{document}
\fakeleft
/\fakeright
can be used interchangeably to produce a bullet without its opposite counterpart.
Best Answer
One solution with multicol