algorithm2e の小文字のプロシージャ名

algorithm2e の小文字のプロシージャ名

procedureでは のalgorithm2eようなキャプションのみが許可されていることは知っています\caption{ProcedureName()}

ただし、手順は小文字で表記したいと思います。

\documentclass[12pt,a4paper]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{enumerate}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage[algosection, boxruled, linesnumbered]{algorithm2e}

\begin{document}
\begin{procedure}

    \SetKwInOut{Input}{input}
    \SetKwInOut{Output}{output}
    \Input{Graph $G = (V,E)$}
    \Output{}
    \ForEach{node $v \in V$}
    {
        \lIf{$v$ is marked}{remove $v$}
    }

    \caption{\textsc{removemarked()}}
    \label{alg:removemarked}

\end{procedure}
\end{document}

もちろんエラーが発生します

Paragraph ended before \algocf@captname was complete

手順の代わりに を使用すると、正常に\begin{algorithm} ... \end{algorithm}フォークします。 でも動作させる方法はありますかprocedure?

答え1

マニュアルには詳しく書かれていませんalgorithm2eが、あなたが望むことを達成するには、コマンドを発行する必要があります

\SetProcNameSty{textsc}

\caption環境を使用する場合の の引数にはprocedure、 のようなものしか含めることができませんname(arg)

次のMWEでは、

\SetProcArgSty{textsc}

引数付きのプロシージャキャプションを使用している場合は、次のようになります。

\documentclass[12pt,a4paper]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{enumerate}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage[algosection, boxruled, linesnumbered]{algorithm2e}

\SetProcNameSty{textsc}
\SetProcArgSty{textsc}

\begin{document}
\begin{procedure}

    \SetKwInOut{Input}{input}
    \SetKwInOut{Output}{output}
    \Input{Graph $G = (V,E)$}
    \Output{}
    \ForEach{node $v \in V$}
    {
        \lIf{$v$ is marked}{remove $v$}
    }

    \caption{removemarked()}
    \label{alg:removemarked}

\end{procedure}
\end{document} 

出力

ここに画像の説明を入力してください

関連情報