I have already tried two things: \makebox[1.2\textwidth][c]{...}
which did not work (perhaps missing \item
). \redefinegeometry
does not work well in this case beacause it’s not on a single page. MWE:
\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\begin{document}
\begin{algorithm}
\caption{Euclid’s algorithm}\label{alg:euclid}
\begin{algorithmic}[1]
\Procedure{Euclid}{$m,l$}\Comment{The g.c.d. of m and l}
\State $r\gets m\bmod l$
\While{$r\not=0$}\Comment{We have the answer if r is 0}
\State $m\gets l$
\State $l\gets r$
\State $r\gets m\bmod l$
\EndWhile\label{euclidendwhile}
\State \textbf{return} $l$\Comment{The gcd is l}
\EndProcedure
\end{algorithmic}
\end{algorithm}
\end{document}
Best Answer
You could make
algorithm
unfloatable and box it with another floatable environment which adapts the width.In the following, an invisible
tcolorbox
is used for this purpose. Adapt thegrow to left by
andgrow to right by
options for the width needed. Also, the float settings are done by thefloat
option.If there are many algorithm boxes to be adapted, you could use the following variant where an environment
talgorithm
is constructed. It takes a symmetric growth value as mandatory parameter and anytcolorbox
option as optional parameter: