\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}
我想让文字环绕在 周围algorithm
。我尝试过以下解决方案这里但似乎没有效果。出于某种原因,文本仍然没有环绕算法。