TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 9 down vote accepted

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

share|improve this answer
great! last question, how can we change the caption text size? – flow Aug 26 '11 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. – Niel de Beaudrap Aug 26 '11 at 11:30
To change the caption put \renewcommand{\AlCapSty}[1]{\normalfont\scriptsize{\textbf{#1}}\unskip} in the environment. – Ulrike Fischer Aug 26 '11 at 11:57
A follow-up question on the line no size. Thanks a lot. tex.stackexchange.com/questions/145932/… – Sibbs Gambling Nov 20 '13 at 1:47

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

share|improve this answer
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. – Niel de Beaudrap Aug 26 '11 at 12:15
@Niel: perhaps update the package. – Stefan Kottwitz Aug 26 '11 at 12:31
just did, still have the problem. Quite odd. – Niel de Beaudrap Aug 26 '11 at 13:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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