KTUG 한국 텍 사용자 그룹

Menu

KTUG :: Q&A 마당

algorithm 환경을 쓰지 않을 때 에러를 일으키는 것은 \caption입니다. 캡션은 원래 figure나 table처럼 떠다니는 개체에서만 쓸 수 있습니다. 따라서 저널에서 algorithm 환경을 쓰지 말라고 했다면, 캡션도 쓰지 않는 것으로 보아야 하지 않을까 싶습니다. 아래 예처럼, 방법이 없지 않겠습니다만, 저널에 먼저 문의를 하는 게 맞지 않을까 싶습니다. 

\documentclass{article}
\usepackage{algpseudocode}
\usepackage{ccaption}
\usepackage{newfloat}
\DeclareFloatingEnvironment[
fileext = loc,
listname = List of Algorithms,
name = Algorithm,
placement = htbp,
]{algorithm} % float 환경을 하나 만들되 쓰지는 않는다. (단지 \alcap 명령을 만들기 위해 필요)
\newfixedcaption{\alcap}{algorithm} % float 환경이 아닌 곳에서도 캡션을 만든다.

\begin{document}
\begin{minipage}{\linewidth} %캡션과 algorithmic 환경 사이가 쪽나눔이 되지 않도록 묶는다
\alcap{Euclid's algorithm}\label{euclid}
\begin{algorithmic}[1]
\Procedure{Euclid}{$a,b$}\Comment{The g.c.d. of a and b}
\State $r\gets a\bmod b$
\While{$r\not=0$}\Comment{We have the answer if r is 0}
\State $a\gets b$
\State $b\gets r$
\State $r\gets a\bmod b$
\EndWhile\label{euclidendwhile}
\State \textbf{return} $b$\Comment{The gcd is b}
\EndProcedure
\end{algorithmic}
\end{minipage}
\end{document}

 

KTUG 한국 텍 사용자 그룹