This question already has an answer here:

I have a long algorithm that's taking three quarter of a page and so it's taking a whole page with an empty quarter. I want it to be continued with the previous text without leaving any empty place, that means that it will be divided into two pages.

I found answers here that allow to divide the algorithm into two previously set parts, however, I want the algorithm to dynamically fit into the two pages. How I can do that?

Here is an example of the situation that I am having:


Qu’est que c’est?. C’est une phrase fran ̧cais avant le lorem ipsum. Loremipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisissem. Nullam nec mi et neque pharetra sollicitudin. Praesent imperdiet minec ante. Donec ullamcorper, felis non sodales commodo, lectus velit ultricesaugue, a dignissim nibh lectus placerat pede. Vivamus nunc nunc, molestie ut,ultricies vel, semper in, velit.
\State \textbf{Entrées:} XXX
\State \textbf{Sortie:} XXX
\State XXX

\For{\texttt{(\textit{i allant de 1 à (T-1)})}}
    \State  XXX

    \For{\texttt{( XXX}}
        \State \textit{XXX}XXX

                \State \textit{XXX} XXX
                \State XXX



        \If{(XXX) } 
            \State xXX



marked as duplicate by Community Jun 7 '17 at 9:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.