
\usepackage[ruled,vlined]{algorithm2e}
\usepackage{framed}
\setlength\FrameSep{5mm}
\begin{document}
\begin{oframed} Some text...
\begin{center}
\begin{algorithm}
\DontPrintSemicolon
\SetKwInOut{Input}{Input}\SetKwInOut{Output}{Output}
\Input{The input to the algorithm}
\Output{The output of the algorithm}
\BlankLine
\caption{This is what the algorithm does}
\end{algorithm}
\end{center}
Some other text...
\end{oframed}
\end{document}
¿Hay alguna manera de eliminar el error 'Secuencia de control no definida', manteniendo el marco (debido a que el algoritmo es parte de un cuadro grande que también contiene otros textos, no quiero eliminar el cuadro)?
Respuesta1
algorithm
es un tipo de float
y float
siempre tiene problemas dentro \vbox
y minipage
, debe usar el paquete float
y usar la opción [H]
y la modificación MWE
es:
\documentclass{book}
\usepackage{float}
\usepackage[ruled,vlined]{algorithm2e}
\usepackage{framed}
\setlength\FrameSep{5mm}
\begin{document}
\begin{oframed} Some text...
\begin{center}
\begin{algorithm}[H]
\DontPrintSemicolon
\SetKwInOut{Input}{Input}\SetKwInOut{Output}{Output}
\Input{$12$ numbered coins, $11$ of which have same weight}
\Output{Number of the fake coin}
\BlankLine
\caption{Finding the fake coin in $3$ measurements}
\end{algorithm}
\end{center}
Some other text...
\end{oframed}
\end{document}