In this example I would like to reduce the pseudocode font size, but only for this slide while keeping the others in the default font size. How can I do that?

3 Answers 3


The simplest way would be to add \small, \footnotesize, \scriptsize, or \tiny immediately after the beginning of the algorithm environment. This changes the size of everything inside the environment (except for the caption), and nowhere else.

Edited to add: This will apparently leave the size of the line-numbers and of the caption unchanged. In order to change the size of the line-numbers for the algorithm, add the command \algsetup{linenosize=<size>} just inside the algorithm environment, where <size> is again something like \small, \footnotesize, etc. Note that the default is to have line-numbers somewhat smaller than the surrounding text: if you want the appearance to be somewhat similar to algorithms elsewhere in your document, you should also choose a smaller size for the line-numbers than the algorithm body.

I am not sure how best to modify the size of the caption, unfortunately.

Example document.

    \FOR{this algorithm only}
      \STATE all of the text in a smaller size of typeface
  \caption{an algorithm with smaller typeface}


some text outside of the environment


    \FOR{all other algorithms}
      \STATE everything normally unless otherwise modified
  \caption{an algorithm with normal typeface}


Algorithms with different sizes of typeface

  • great! last question, how can we change the caption text size? Aug 26, 2011 at 10:53
  • @flow: Unfortunately, I can't figure out a graceful way to do so. I just found out that my original answer also did not modify the size of the line-numbers: I've revised my answer to describe how to do that, at least. Aug 26, 2011 at 11:30
  • 1
    To change the caption put \renewcommand{\AlCapSty}[1]{\normalfont\scriptsize{\textbf{#1}}\unskip} in the environment. Aug 26, 2011 at 11:57
  • A follow-up question on the line no size. Thanks a lot. tex.stackexchange.com/questions/145932/… Nov 20, 2013 at 1:47
  • 1
    I am having ! Undefined control sequence for \algsetup {linenosize=\small} how can I fix it?
    – alper
    Oct 4, 2023 at 19:39

algorithm2e provides commands for customizing pseudocode font shape and size, algorithmic does that for line numbering. For example:

  • 1
    Curious. When I compile this with a simple example, I get Undefined control sequence: \SetAlCapNameFnt, even though the command is clearly mentioned in the algorithm2e documentation. Aug 26, 2011 at 12:15
  • @Niel: perhaps update the package.
    – Stefan Kottwitz
    Aug 26, 2011 at 12:31
  • just did, still have the problem. Quite odd. Aug 26, 2011 at 13:33

I am answering a part of question, rest are already answered.

To reduce the size of caption just use the \small or \tiny inside the caption i.e., \caption{<here> your_caption}. For e.g., \caption{\tiny My Algorithm}.

  • 1
    Welcome to TeX.SE :) // Thanks for your answer. However, your solution was already proposed. If you allow me a suggestion, it may be a good idea to check answers already given, first ;-) // See you next time.
    – MS-SPO
    Sep 11, 2021 at 15:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .