# Insert indent in algorithm at line break of the same \State

I have the following code:

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

\begin{document}

\begin{algorithm*}[t!]
\caption{caption}
\begin{algorithmic}[1]
\Require{require}
\State {testttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt}
\Return{return a}
\end{algorithmic}
\end{algorithm*}
\end{document}


How can I break a line in a \State and begin new line at the same indent as the previous line?

It's done automatically:

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

\begin{document}

\begin{algorithm*}[t!]
\caption{caption}
\begin{algorithmic}[1]
\Require{require}
\State {test tttt tttt tttt tttt tttt tttt tttt tttt tttt tttt
tttt tttt tttt tttt tttt tttt tttt tttt tttt tttt tttt}
\Return{return a}
\end{algorithmic}
\end{algorithm*}
\end{document}


• Thanks! However, this doesn't seem to work in all cases. See this question: tex.stackexchange.com/questions/398733/…
– pir
Oct 30 '17 at 16:22
• @pir That's a bug in algpseudocode, as far as I can see. Or the idea is that paragraphs are not allowed in \While Oct 30 '17 at 16:57
• Okay, any idea how to fix that?
– pir
Oct 30 '17 at 20:05
• Do you think it would work if I switched to another package similar to algpseudocode?
– pir
Oct 30 '17 at 20:31
• This worked for me: tex.stackexchange.com/questions/314023/… May 7 '18 at 16:54