I have a document with a few tables that have their captions formatted like this
which I achieved using
\usepackage[format=plain, justification=raggedright,singlelinecheck=true]{caption}
\captionsetup[table]{labelsep=newline, textfont=it, singlelinecheck=false, margin=1em}
and I would like to use the same layout for algorithms. I did find out from the package-readme and this page that I need
\usepackage[plainruled]{algorithm2e}
to remove the top rule above the caption and get this:
Next, I understand I need to define my own macro style
to be able to use
\SetAlgoCaptionLayout{style}
but I am confused how to create the macro and how to left-align, use normalfont in footnotesize for the algorithm heading, insert the line break, and italicize the caption text.
MWE:
\documentclass{article}
\usepackage[plainruled]{algorithm2e}
\begin{document}
\begin{algorithm}
{\footnotesize
\caption{An example}
some text\;
}
\end{algorithm}
\end{document}
\documentclass{article} \usepackage[algoruled]{algorithm2e} \renewcommand{\AlCapNameFnt}{\normalfont\itshape} \renewcommand{\AlCapFnt}{\normalfont} \SetAlgoCaptionSeparator{\\} \begin{document} \begin{algorithm} {\footnotesize \caption{An example} some text\; } \end{algorithm} \end{document}
plainrule
, where\SetAlgoCaptionSeparator{\\}
does not work and the caption is below the body and centered. I useplainruled
to get rid of the top rule above the caption. Is there perhaps a way of getting this done inalgoruled
? That would solve things!plainruled
puts the caption at the bottom, which is different from the visual of putting the (table) caption at the top.