I would like to create a "Parameter: …" section, similar to the "Input: …" and "Output: …" sections in my algorithm description. The parameters are global, user-defined constants, known before the algorithm is run.
I have tried to define a new keyword with the text "Parameter" but of course that does the wrong thing (among others: the line is numbered but it should not be, everything behind the "Parameter:" is in italics but I don't want it to be).
How can I create a parameter section similar to Input and Output?
Gonzalo Medina's answer almost does the right thing but I get a superfluous colon on a separate line.
Code:
\documentclass[preprint,3p,12pt,times]{elsarticle}
\usepackage{ecrc}
\usepackage[linesnumbered,algoruled,boxed,lined]{algorithm2e}
\volume{00}
\firstpage{1}
\journalname{Some journal}
% Would work correctly with these lines:
% \documentclass{article}
% \usepackage[linesnumbered,algoruled,boxed,lined]{algorithm2e}
\SetKwInOut{Parameter}{Parameters}
\begin{document}
\begin{algorithm}[H]
\KwIn{Some input}
\Parameter{Some parameter}
\KwOut{Some output}
\caption{Some algorithm}\label{alg.mainLoop}
\end{algorithm}
\end{document}
I guess it is some macro clash among the packages. Any workaround would be greatly appreciated.
Best Answer
You can use
and then
in you algorithms. A complete example:
After the edit to the question, there's some incompatibility between
elsarticle
and the new definition; in this case, you can move the new definition inside thealgorithm
environment which can be done on a on-per-one basis or, as Werner suggested inhis comment
, can be automated usingA complete example: