0
\documentclass{article}
\usepackage{algorithm} 
\usepackage[noend]{algpseudocode}
\usepackage{float}
\usepackage{lipsum}
\newfloat{algorithm}{t}{lop}
\begin{document}

This text comes before the algorithm. \lipsum[2-4]

\begin{algorithm}[t]
\caption{An algorithm with caption}\label{alg:cap}
\begin{algorithmic}
\Require $n \geq 0$
\Ensure $y = x^n$
\State $y \gets 1$
\State $X \gets x$
\State $N \gets n$
\While{$N \neq 0$}
\If{$N$ is even}
    \State $X \gets X \times X$
    \State $N \gets \frac{N}{2}$  \Comment{This is a comment}
\ElsIf{$N$ is odd}
    \State $y \gets y \times X$
    \State $N \gets N - 1$
\EndIf
\EndWhile
\end{algorithmic}
\end{algorithm}

This comes after.  \lipsum[1-2]
\end{document}

I want to wrap text around an algorithm. I've tried the solution here but that didn't seem to work. For some reason the text is still not wrapping around the algorithm. enter image description here

Adrian
  • 471

0 Answers0