'oframed'환경의 알고리즘

Sep 21 2020
\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 MadyYuvi Sep 21 2020 at 13:34

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}