.png)
다음 M(not)WE가 작동해야 합니다. 버그를 찾았나요?
\documentclass{article}
\usepackage{algorithm2e}
\SetKwSwitch{Switch}{Case}{Other}{Switch}{:}{Case}{Other}{}
\begin{document}
\begin{algorithm}
\Switch{X}{
\Case{1}{A}
\Other{Other}
}
\end{algorithm}
\end{document}
답변1
버그 없음: \SetKwSwitch
필요아홉인수 중 8개만 제공하므로 \par
빈 줄에 의해 생성된 인수는 9번째로 간주됩니다. 그리고 \par
아홉 번째 인수가 사용되는 맥락에서는 불법입니다.
\newcommand{\SetKwSwitch}[9]{% #1=\Switch #2=\Case #3=\Other #4=switch #5=do #6=case #7=otherwise #8=endcase #9=endsw
% \algocf@newcmdside{#1}{3}%
\algocf@newcmdside@koif{#1}%
{\KwSty{#4}\algocf@scond\ArgSty{##2}\algocf@econd\KwSty{#5}\ifArgumentEmpty{##1}\relax{ ##1}\algocf@block{##3}{#9} {##4\relax}}%
매뉴얼에는 마지막 (기호) 인수가 중괄호로 묶이지 않은 설명이 있으므로 버그가 있지만 문서에만 있습니다. 39페이지 11.6절 시작 부분에서 다음을 읽었습니다.
\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endcase}endsw
하지만 그래야 해
\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{endcase}{endsw}
수정된 예:
\documentclass{article}
\usepackage{algorithm2e}
\SetKwSwitch{Switch}{Case}{Other}{Switch}{:}{Case}{Other}{EndCase}{EndSwitch}
\begin{document}
\begin{algorithm}
\Switch{X}{
\Case{1}{A}
\Other{Other}
}
\end{algorithm}
\end{document}