
\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}
프레임을 유지하면서 '정의되지 않은 제어 시퀀스' 오류를 제거할 수 있는 방법이 있습니까? (알고리즘은 다른 텍스트도 포함하는 큰 상자의 일부이기 때문에 상자를 제거하고 싶지 않습니다.)
답변1
algorithm
은(는) 유형 중 하나 float
이며 float
항상 내부에 문제가 있습니다 \vbox
. minipage
패키지 float
와 옵션을 사용해야 하며 [H]
수정된 MWE
내용은 다음과 같습니다.
\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}