0

I have the following code for an algorithm.

\begin{algorithm}
    \label{alg:script}
    \caption{Algorithm to calculate something} 
    \begin{algorithmic}[1]
    \State One line sentence
        \For {\texttt{i}}
            \State Really long sentence that messes up the pseudocode and needs to be formatted
                \For {\texttt{each j}}                  \State Really long sentence that messes up the pseudocode and needs to be formatted
                    \State Really long sentence that messes up the pseudocode and needs to be formatted
                \EndFor
            \State Really long sentence that messes up the pseudocode and needs to be formatted
            \State Really long sentence that messes up the pseudocode and needs to be formatted
          \EndFor
        \State Final step
    \end{algorithmic} 
\end{algorithm}

The really long description I need to give in my pseudo code messes up my formatting. For example, in line 3, the code extends beyond the for loop above it. Same for lines 5, 6, 8 and 9. I tried using different algorithm packages but I can't get it to format the way I want it to. Can someone help me?

Edit I want the lines indented to match the lines it started from. I have about 10 long sentences overall.

enter image description here

user42
  • 125
  • What are you wanting to happen? The long sentence runs off the end and you only see part of it? The long sentence continues on the next line, but is indented to match the line it started from? Is indented more than the line it started from? The long sentence gets cut off at the end and is continued in a footnote? How many long sentences do you have? – Teepeemm Jul 11 '21 at 20:40
  • @Teepeemm, I have edited my question to explain what I want. – user42 Jul 11 '21 at 20:50
  • @user42, would the answers at https://tex.stackexchange.com/questions/78776/forced-indentation-in-algorithmicx help? – citsahcots Jul 11 '21 at 21:14

0 Answers0