Many of the algorithms I have with the algorithm2e
package do not extend across the page width. If I use the package's boxruled
or ruled
options, the result is a box or rule that extends the pagewidth with a lot of whitespace on the right side.
I have changed the width of the algorithm itself using \setlength{\algomargin}{2in}
but this does not have an effect on the width of the rules. The effect is to 'center' the algorithm code, but leave the environment itself the width of the page.
Is there a way to change that without having to squeeze it into a minipage
?
UPDATE:
Minimal example:
\documentclass[10pt]{article}
\usepackage[ruled]{algorithm2e}
\begin{document}
\setlength{\algomargin}{2in}
\begin{algorithm}[t]
\caption{NaiveSelect}\label{algo:naive-option}
Some alg step \;
\end{algorithm}
\end{document}
Best Answer
Based on @lockstep answer, I've created a wrapper environment which allows the minipage width to be specified as an argument.
Use it like this
For this result