# writing algorithm in a table

I want to write an algorithm such that what I have attached, I am somehow elementary in writing algorithms with latex. I do not want the exact answer, only a tip or an example similar to what I have attached.

• Use \minipage to encapsulate the code display and then place them in the appropriate cells of the table. – R. Schumacher May 16 '15 at 18:27
• Something like this? – Alenanno May 16 '15 at 19:33
• – John Kormylo May 17 '15 at 15:24
• Did the question John Kormylo linked to solve your problem? – Torbjørn T. May 23 '15 at 20:22

You can do any one of the following:

1. Place the algorithms each in its own minipage environment:

\begin{minipage}{.5\textwidth}
\begin{algorithm}[H]% Left algorithm
...
\end{algorithm}
\end{minipage}%
\begin{minipage}{.5\textwidth}
\begin{algorithm}[H]% Right algorithm
...
\end{algorithm}
\end{minipage}%

2. Place the algorithms inside the columns of a larger table.

I've chosen (2) above to produce this (with the help of booktabs:

Symbols and other notation may have to change. It's just to give you an idea of what could be done.

\documentclass{article}

\usepackage[margin=1in]{geometry}% Just for this example

\usepackage[lined]{algorithm2e}
\usepackage{amsmath,tabularx,booktabs}

\DontPrintSemicolon

\newcommand{\vectnotation}[1]{\textbf{\textit{#1}}}
\DeclareMathOperator{\Vect}{vec}
\newcommand{\vect}[1]{\Vect(#1)}
\newcommand{\assign}{\leftarrow}
\newcommand{\To}{\textup{\textbf{to}}}

\begin{document}

\noindent
\begin{tabularx}{\textwidth}{XX}
\toprule
\multicolumn{2}{p{\dimexpr\textwidth-2\tabcolsep}}{\refstepcounter{algocf}\AlCapSty{\AlCapFnt\algorithmcfname\nobreakspace\thealgocf:}
Efficient application of the wavelet dictionary by the Horner's rule.} \\
\midrule
\begin{algorithm}[H]
Forward operator $(y = \vectnotation{D} \vect{\vectnotation{X}})$\;
$\vectnotation{R} \assign \mathbf{1} \otimes \vectnotation{X}(N,:)$\;
\For{$n \assign 2$ \To{} $N$}{
$\vectnotation{P} \assign \mathbf{1} \otimes \vectnotation{X}(N-n+1,:)$\;
$\vectnotation{R} \assign \vectnotation{R} \circ \vectnotation{Z} + \vectnotation{P}$\;
}
$\vectnotation{y} \assign \vectnotation{F}^{-1}(\hat{\vectnotation{w}} \circ \vectnotation{R}\mathbf{1})$\;
\end{algorithm} &
\begin{algorithm}[H]
Adjunct operator $(\vect{\tilde{\vectnotation{X}}} = \vectnotation{D}^{T} \vectnotation{y})$\;
$\mathbf{\rho} \assign \vectnotation{y}^{T} \vectnotation{W}\vectnotation{F}$\;
$\vectnotation{L} \assign N \times M$ all-ones matrix\;
\For{$n \assign 2$ \To{} $N$}{
$\tilde{\vectnotation{X}}(n,:) \assign \mathbf{\rho} \vectnotation{L}$\;
$\vectnotation{L} \assign \vectnotation{Z}^{\star} \circ \vectnotation{L}$\;
}
\end{algorithm} \\[-\normalbaselineskip]
\bottomrule
\end{tabularx}

\end{document}