[Tex/LaTex] Indentation in algorithmic package when having multiple lines

algorithmicindentationpseudocode

I'm using algorithmic package and I've got this code:

\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocode}
\begin{document}
\begin{algorithmic}[1]
\Function {BalanceCascade}{}
\State $i \leftarrow 0, f \leftarrow \sqrt[T-1]{\frac{\left | P \right |}{\left | N \right |}}$, some very very very very very very very very very very very very very very very very long goes here, so this will create a few new lines
\EndFunction 
\end{algorithmic}
\end{document}

And I've got the following result:
enter image description here
Is it there a way to indent the new lines to be under the start of the first one?

Update: If I do the solution proposed by @Bobyandbob the lines get too closer:
enter image description here
Theres no space between lines and end function.

Best Answer

First I show what you had, then I show it in a \parbox, trying to use some horizontal list lengths to get the width right (it is close, but not quite right). Finally, I again use a \parbox, but specify the width manually to match the right margin.

To get the proper vertical placement and spacing, I had to use the [t] option of \parbox and also end it with a \strut.

\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocode}
\begin{document}
\begin{algorithmic}[1]
\Function {BalanceCascade}{}
\State $i \leftarrow 0, f \leftarrow \sqrt[T-1]{\frac{\left | P \right |}{%
  \left | N \right |}}$, some very very very very very very very very very
  very very very very very very very long goes here, so this will create a 
  few new lines
\EndFunction 

\Function {BalanceCascade}{}
\State \parbox[t]{\dimexpr\textwidth-\leftmargin-\labelsep-\labelwidth}{%
  $i \leftarrow 0, f \leftarrow \sqrt[T-1]{\frac{\left | P \right |}{%
  \left | N \right |}}$, some very very very very very very very very very
  very very very very very very very long goes here, so this will create a 
  few new lines\strut}
\EndFunction 

\Function {BalanceCascade}{}
\State \parbox[t]{313pt}{%
  $i \leftarrow 0, f \leftarrow \sqrt[T-1]{\frac{\left | P \right |}{%
  \left | N \right |}}$, some very very very very very very very very very
  very very very very very very very long goes here, so this will create a 
  few new lines\strut}
\EndFunction 
\end{algorithmic}

\noindent Here is the left margin
\end{document}

enter image description here

Related Question