I know that procedure
in algorithm2e
only allows captions like \caption{ProcedureName()}
.
However, I'd like my procedure to appear in small caps:
\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}
Which of course gives error
Paragraph ended before \algocf@captname was complete
Instead of procedure, if I use \begin{algorithm} ... \end{algorithm}
, then it forks fine.
Is there a way to make it work in procedure
as well?
Best Answer
It's not really well documented in
algorithm2e
manual, but to achieve what you want, you have to issue the commandThe argument of
\caption
when using theprocedure
environment can only contain something likename(arg)
.In the following MWE I've also added
just in case you are using procedure captions with arguments:
Output