I'm writing the pseudocode of an algorithm, however, I'm using a template with big margins. I wanted to increase the space occupied by the algorithm so all the comments can fit in one line only. So far I have this:
\begin{algorithm}
\begin{algorithmic}[1]
\ForAll{pixels k}
\State $f_k\gets 0$
\ForAll{pulses p}
\State $R\gets || a_k - v_p ||$ \Comment{calculate distance from platform to pixel}
\State $bin\gets \lfloor (R - R0)/\Delta R \rfloor$ \Comment{range bin (integer)}
\If{$bin \in [0, N_bp - 2]$}
\State $w\gets \lfloor (R - R0)/\Delta R \rfloor - bin$ \Comment{interpolation weight}
\State $s\gets (1 - w)\cdot g(p, bin) + w \cdot g(p, bin + 1)$ \Comment{data sampled using linear interpolation}
\State $f_k\gets f_k + e^{j \cdot ku \cdot R}$ \Comment{add pulse's contribution to the pixel}
\EndIf
\EndFor
\EndFor
\end{algorithmic}
\caption{Backprojection algorithm pseudocode. \\ \textbf{Source:} PERFECT Manual Suite \cite{perfect2013}.}
\label{alg-bp}
\end{algorithm}
It looks like this:
How can I increase the horizontal size occupied by the algorithm?
Thank you.
Best Answer
It looks awkward, but you can do it:
You can set the
algorithm
using the[H]
ere option, which allows you to box it. In turn, this allows you to adjust the margins; above I've added5em
to the total width (or2.5em
on either side, since the\makebox
centres its contents).The algorithm is still allowed to float, since the
algorithm
box is placed inside a floatingfigure
environment.I'd be more inclined to adjust the pseudocode and stacking some of the elements to create more room (either the pseudocode, or the comment):