I am writing pseudocode using the algorithmicx package in IEEEtran class (double column). My problem is, some of the statement in the code are quite long which I expected to wrap to next line. However, the lines are overflowing out of the margin, something like:
\documentclass[10pt,conference,letterpaper]{IEEEtran}
\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
\begin{document}
\begin{algorithm}
\caption{Network similarity}
\begin{algorithmic}[2]
\Require{$G\_ref, G\_tar,ref\_community, tar\_community$}
\ForAll{$ref\_node \in G\_ref $}
\ForAll{$tar\_node \in G\_tar$}
\State{ $pair\_sim\_table[ref\_node,tar\_node] \gets Calculate\_similarity(ref\_feature\_vec[ref\_node],tar\_feature\_vec[tar\_node])$}
\EndFor
\EndFor \\
\Return pair\_sim\_table, cluster\_sim
\end{algorithmic}
\end{algorithm}
\end{document}
Since the code associated with the \State command is quite long, it overflows out of the margin, instead of wrapping around. Excuse me if this is a trivial question. Any help would be appreciated !


algorithmicwhile maintaining indentation. If such manual intervention is what you're after, then I would consider this a duplicate, since the answer there should solve your problem (using something like\Statexor perhaps thevarwidthpackage). Give some feedback after investigating. – Werner Jul 08 '12 at 22:52varwidthpackage did it for me. Thanks a lot. Is it required to delete this question (if it is possible ) since the answer to it was actually given in an earlier post ? – R.Bahl Jul 08 '12 at 23:21