3

I'm writing up a pseudo-algorithm using the algpseudocode package. Most of my code lines fit without line wrapping, but a single line of code cannot fit in a single line of the table. When the code continues onto the next line, it starts all the way to left, making it look strange. How do I make this continued line start on the same indentation level?

It seems to be related to the use of a while loop. I've modified the code from Insert indent in algorithm at line break of the same \State to reproduce the error:

\documentclass[12pt,a4paper,twoside]{book}
\usepackage{graphicx}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}

\begin{document}

\begin{algorithm}
\caption{caption}
\begin{algorithmic}
\Require{require}
\While{...}
\State{test tttt tttt tttt tttt tttt tttt tttt tttt tttt tttt
        tttt tttt tttt tttt tttt tttt tttt tttt tttt tttt tttt}
\EndWhile
\State \Return{return a}
\end{algorithmic}
\end{algorithm}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.