# Place two algorithm into two column

I have single column page. I would like to add my two algorithm into two column. How can I do this? My algorithms are below.

\begin{algorithm}[h]
\caption{Resolve 1}
\begin{algorithmic}
\scriptsize
\STATE $P_i$ sends $id,t_1,t_2,P_j,h_j$ to TTP where $P_j$ is the party that does not send $V_j^{(2)}$ to $P_i$, TTP does the following and sends the returned message to $P_i$:

\IF{$currenttime > t_1$}
\STATE \textbf{send} $msg$ Abort Resolve 1"
\ELSE
\IF { Search($id, t_1, t_2$) == NULL }
\STATE \lst = Create($id, t_1, t_2$)
\STATE \slst = Create($id, t_1, t_2$)
\STATE \lst.add($P_i, (P_j,h_j)$)
\STATE \textbf{send} $msg$ Come after $t_2$"
\ELSE
\STATE \lst.add($P_i, (P_j,h_j$))
\STATE \textbf{send} $msg$ Come after $t_2$"
\ENDIF
\ENDIF
\end{algorithmic}
\end{algorithm}

\begin{algorithm}[h]
\caption{Resolve 3}
\begin{algorithmic}
\scriptsize
\STATE $P_i$ comes either to receive decryption of a $\{V^(2)_t\}_{t \in M}$ where $M \subseteq N$ or his desired decryption shares from TTP's record.
\STATE $condition$  =  \lst.isEmpty()
\IF {$condition$ is false }
\STATE \textbf{send} msg Protocol is aborted"
\ELSE
\IF {$P_i$ give $\{V^(2)_t\}_{t \in M}$}
\FORALL {$t$ in $M$}
\STATE \textbf{send} Decrypt($sk, V^(2)_t$)
\ENDFOR
\ELSE
\FORALL {$t$ in $\slst$ as $(P_i, shares_t)$}
\STATE \textbf{send} $shares_t$
\ENDFOR
\ENDIF
\ENDIF

\end{algorithmic}
\end{algorithm}

• Can you please update your question, so that the TeX part is a complete, compilable example? That will allow others to help more effectively. May 26, 2014 at 19:12
• Could you make the whole document two column? Or are you specifically trying to compare these two algorithms side-by-side? May 26, 2014 at 19:13

Do you mean like this? I have used mulitcols inside algorithmic with a \columnbreak between the algorithms. Note there is only one caption command available.

\documentclass{article}

\usepackage{algorithm,algorithmic,multicol}

\begin{document}

\begin{algorithm}[h]
\caption{Resolve 1 and 3}
\begin{multicols}{2}
\begin{algorithmic}
\scriptsize
\STATE $P_i$ sends $id,t_1,t_2,P_j,h_j$ to TTP where $P_j$ is the party that does not send $V_j^{(2)}$ to $P_i$, TTP does the following and sends the returned message to $P_i$:

\IF{$currenttime > t_1$}
\STATE \textbf{send} $msg$ Abort Resolve 1"
\ELSE
\IF { Search($id, t_1, t_2$) == NULL }
\STATE lst = Create($id, t_1, t_2$)
\STATE slst = Create($id, t_1, t_2$)
\STATE lst.add($P_i, (P_j,h_j)$)
\STATE \textbf{send} $msg$ Come after $t_2$"
\ELSE
\STATE logical lst.add($P_i, (P_j,h_j$))
\STATE \textbf{send} $msg$ Come after $t_2$"
\ENDIF
\ENDIF
\end{algorithmic}
\columnbreak
\begin{algorithmic}
\scriptsize
\STATE $P_i$ comes either to receive decryption of a $\{V^(2)_t\}_{t \in M}$ where $M \subseteq N$ or his desired decryption shares from TTP's record.
\STATE $condition$  =  lst.isEmpty()
\IF {$condition$ is false }
\STATE \textbf{send} msg Code
Protocol is aborted"
\ELSE
\IF {$P_i$ give $\{V^(2)_t\}_{t \in M}$}
\FORALL {$t$ in $M$}
\STATE \textbf{send} Decrypt($sk, V^(2)_t$)
\ENDFOR
\ELSE
\FORALL {$t$ in $slst$ as $(P_i, shares_t)$}
\STATE \textbf{send} $shares_t$
\ENDFOR
\ENDIF
\ENDIF
\end{algorithmic}
\end{multicols}
\end{algorithm}

\end{document}


Setting each in a separate box is another way of displaying them side-by-side:

\documentclass{article}
\usepackage[margin=1in]{geometry}% Just for this example
\usepackage{algorithm,algcompatible,lipsum}
\algnewcommand{\lst}{\texttt{lst}}
\algnewcommand{\slst}{\texttt{slst}}
\algnewcommand{\SEND}{\textbf{send}}

\newsavebox{\algleft}
\newsavebox{\algright}

\savebox{\algleft}{%
\begin{minipage}{.49\textwidth}
\begin{algorithm}[H]
\caption{Resolve 1}
\begin{algorithmic}
\scriptsize
\STATE $P_i$ sends $id,t_1,t_2,P_j,h_j$ to TTP where $P_j$ is the party that does not send $V_j^{(2)}$ to $P_i$, TTP does the following and sends the returned message to $P_i$:
\IF{$\mbox{currenttime} > t_1$}
\STATE \SEND{} msg Abort Resolve 1''
\ELSE
\IF { Search($id, t_1, t_2$) == NULL }
\STATE \lst{} = Create($id, t_1, t_2$)
\STATE \slst{} = Create($id, t_1, t_2$)
\STATE \lst.add($P_i, (P_j,h_j)$)
\STATE \SEND{} msg Come after $t_2$''
\ELSE
\STATE \lst.add($P_i, (P_j,h_j$))
\STATE \SEND{} msg Come after $t_2$''
\ENDIF
\ENDIF
\end{algorithmic}
\end{algorithm}%
\end{minipage}}%
\savebox{\algright}{%
\begin{minipage}{.49\textwidth}
\begin{algorithm}[H]
\caption{Resolve 3}
\begin{algorithmic}
\scriptsize
\STATE $P_i$ comes either to receive decryption of a $\{V^{(2)}_t\}_{t \in M}$ where $M \subseteq N$ or his desired decryption shares from TTP's record.
\STATE $\mbox{condition}$  =  \lst.isEmpty()
\IF {$\mbox{condition}$ is false }
\STATE \SEND{} msg Protocol is aborted''
\ELSE
\IF {$P_i$ give $\{V^{(2)}_t\}_{t \in M}$}
\FORALL {$t$ in $M$}
\STATE \SEND{} Decrypt($sk, V^{(2)}_t$)
\ENDFOR
\ELSE
\FORALL {$t$ in $\slst$ as $(P_i, \mbox{shares}_t)$}
\STATE \SEND{} $\mbox{shares}\_t$
\ENDFOR
\ENDIF
\ENDIF
\end{algorithmic}
\end{algorithm}
\end{minipage}}%

\begin{document}

\lipsum[2]

\noindent\usebox{\algleft}\hfill\usebox{\algright}%

\medskip

\lipsum[2]

\end{document}


One option would be to use the multicol package:

\documentclass[a4paper]{article}

\usepackage{multicol}

\begin{document}

single column text...

\begin{multicols}{2}
algorithm 1
algorithm 2
\end{multicols}

single column text...

\end{document}
`