캡션에 절차가 포함된 의사 코드

캡션에 절차가 포함된 의사 코드

나는 그것과 비슷한 의사 코드를 가지려고 노력하고 있습니다.이 기사. 현재 알고리듬x 패키지를 사용하고 있습니다. 내 문제는 캡션을 아래와 같이 만들고 싶다는 것입니다.

여기에 이미지 설명을 입력하세요

따라서 대문자로 작성하고 인수로 완료하십시오. 이 작업을 수행하는 방법을 알 수 없는 것 같습니다. 아래는 예시입니다. 기본적으로 나는 "Euclid(a,b)"가 캡션 뒤에 있는 본문 대신에 포함되기를 원합니다.절차.

\documentclass[11pt]{article} 

\usepackage[utf8]{inputenc}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}

\floatname{algorithm}{Procedure}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\renewcommand\thealgorithm{}

\begin{document}

\begin{algorithm}
\caption{Euclid’s algorithm}
\begin{algorithmic}[1]
\Require Integers $a$ and $b$
\Ensure The g.c.d of $a$ and $b$
\Procedure{Euclid}{$a,b$}
\State $r\gets a\bmod b$
\While{$r\not=0$}
\State $a\gets b$
\State $b\gets r$
\State $r\gets a\bmod b$
\EndWhile
\State \textbf{return} $b$
\EndProcedure
\end{algorithmic}
\end{algorithm}

\end{document}

답변1

트릭은 \textproc아래와 같이 사용하는 것입니다.

\documentclass[11pt]{article} 

\usepackage[utf8]{inputenc}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}

\floatname{algorithm}{Procedure}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\renewcommand\thealgorithm{}

\begin{document}

\begin{algorithm}
\caption{\textproc{Euclid}$(a,b)$}
\begin{algorithmic}[1]
\Require Integers $a$ and $b$
\Ensure The g.c.d of $a$ and $b$
\State $r\gets a\bmod b$
\While{$r\not=0$}
\State $a\gets b$
\State $b\gets r$
\State $r\gets a\bmod b$
\EndWhile
\State \textbf{return} $b$
\end{algorithmic}
\end{algorithm}

\end{document}

이로 인해여기에 이미지 설명을 입력하세요

덧붙여서, 이것은 또한 당신이 원할 때 유용합니다본문의 알고리즘을 참조하세요..

관련 정보