I am writing pseudo code in the algorithmic environment. It is quite long and doesn't fit on one single page. I tried with many option but cannot divide into 2 pages. In another file (since this is thesis) I declared packages for:
\usepackage[vlined,linesnumbered]{algorithm2e} % Algorithm
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{algcompatible}
Here is my code:
\begin{figure}[h]
\small
\hrule
\vspace{2mm}
\textbf{Reader Operation}
%\vspace{1mm}
\begin{algorithmic}[1]
\STATE $ws = 1$
\STATE FQwT([\textquoteleft 0'],$ws$); FQwT([\textquoteleft 1'],$ws$)
\STATE function $FQwT$(char [] $query,$ int $ws$)
\STATE $k = ID.length$
\STATE $L = query.length$
\STATE $c_g=k-L$
\STATE $s=log2(ws)$
\STATE broadcast([$query], s$)
\STATE $[winMatch,crcCheck] = $receiveResponses()
\IF{$nSuccess=0$}
\STATE{$Phase1$}
\IF{$isempty$($winMatch$)}
\STATE $nIdles ++$
\ELSE [$crcCheck = 0$]
\STATE $nCollisions ++$
\IF{$ws=1$}
\STATE $Store$ $c_g$ $with$ $query$ $into$ $LIFO$ $(c_g=k-L)$
\STATE $FQwT$([$query$, \textquoteleft 0'],$ws$); FQwT([$query$, \textquoteleft 1'],$ws$)
\ELSE
\STATE $ws = 1$
\STATE $FQwT$ ([$query$],$ws$); FQwT([$query$],$ws$)
\ENDIF
\ELSE [$crcCheck=1$]
\IF{$L + ws < k$}
\STATE $nGoons ++$
\STATE $ws=ws ++$
\STATE FQwT($[query,winMatch],ws$)
\ELSE [$L + ws = k$]
\STATE $ws=1$
\STATE $nSuccess ++$
\ENDIF
\ENDIF
\ELSE
\STATE{$Phase2$}
\IF{isempty($winMatch$)}
\STATE $nIdles ++$
\ELSE[$crcCheck = 0$]
\STATE $nCollisions ++$
\STATE FQwT([$query$, \textquoteleft 0'],$ws$); FQwT([$query$, \textquoteleft 1'],$ws$)
\ELSE[$crcCheck = 1$]
\IF{$L + ws < k$}
\STATE $nGoons ++$
\STATE $ ws=f(c_g,L)$
\STATE $s= log2(ws)$
\STATE FQwT([$query$, $winMatch$],$ws$);
\ELSE[$L + ws = k$]
\STATE $nSuccess ++$
\ENDIF
\ENDIF
\ENDIF
\end{algorithmic}
\vspace{1mm}
\hrule
\vspace{2mm}
\textbf{Tag Operation}
\vspace{1mm}
\begin{algorithmic}[1]
\STATE $receive(query, s)$
\STATE $L = query.length$
\STATE $ws=2^s$
\IF{$query = ID[0:L-1]$}
\STATE $CRC=$ crc($ID[L:L{+}ws]$)
\STATE backscatter($ID[L:L{+}ws],CRC$)
\ENDIF
\end{algorithmic}
\vspace{1mm}
\hrule
\caption{Pseudo-code of FQwT.
First, the operation of the reader is presented, then the tag operation.}
\label{Fig:dis53}
\end{figure}
Best Answer
To break your algorithm over two pages, then use Werner's handy
breakablealgorithm
environment as described here.Add this code to your preamble:
Then surround your
algorithmic
with\begin{breakablealgorithm}
and\end{breakablealgorithm}
. Thus:EDIT: If I stuff your long algorithm into Werner's environment, then it works perfectly well.
If it works for you, all credit to Werner.