I wish to obtain a boxed algorithm with the caption at the top. I also need to control the caption format, and the heading.
I tried using the algorithm package:
%algorithms
\usepackage[boxed]{algorithm}
\usepackage{algorithmicx,algpseudocode}
% Change float style of algorithm from "ruled" to "plaintop"
\floatstyle{plaintop}
\restylefloat{algorithm}
% Change caption format
\captionsetup[algorithm]{font=scriptsize,labelformat=bf-gara,justification=raggedright,singlelinecheck=false,name=Algorithm}
% Change caption heading
\renewcommand{\thealgorithm}{A.\arabic{algorithm}}
which however does not draw the box around the algorithm. I could require all floats to be boxed, but this would affect figures and tables too, which I do not want to be boxed.
Alternatively, I could use the algorithm2e
package , which offers more control over caption position, but then I get into troubles when I need to specify caption format and heading:
\thealgorithm undefined. \renewcommand{\thealgorithm}
Argument of \ALG@cmd@2@algorithmiccomment has an extra }. \While{$r\not=0$}\Comment{
How can I save both ways? Thanks!
Best Answer
Write yourself a new style based on the old
boxed
style: