8

In the caption of an algorithm created with algorithm2e,

\documentclass{article}

\usepackage[ruled]{algorithm2e}

\begin{document}

\begin{algorithm}[H]
\caption{Caption.}
pseudocode
\end{algorithm}

\end{document}

"Algorithm 1:" comes out bold. How could I change its font, say, to small caps?

Also, how could I make "Algorithm 1." appear instead?

7

The algorithm2e package offers \SetAlgoCaptionSeparator to change the caption separator and \AlCapFnt to control the font for the label of the caption:

\documentclass{article}
\usepackage[ruled]{algorithm2e}

\SetAlgoCaptionSeparator{.}
\renewcommand\AlCapFnt{\normalfont\scshape}

\begin{document}

\begin{algorithm}[H]
\caption{Caption.}
pseudocode
\end{algorithm}

\end{document}

enter image description here

  • 1
    Thanks. I've seen \renewcommand{\AlCapSty}{\textsc} used instead of \renewcommand\AlCapFnt{\normalfont\scshape} (in this example). Do they do the same thing? Is one safer to use than the other? – MSC May 14 '13 at 15:49
  • 2
    @MSC \renewcommand{\AlCapSty}{\textsc} is wrong and it will produce errors, since \textsc expects an argument. Using the font switch \scshape, as in my answer, is the right way to do the redefinition. – Gonzalo Medina May 14 '13 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.