Sign up ×
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.


Syntax-highlighted source code image listings are being used as Algorithm floats with the lst: prefix for captions.


The following LaTeX code in the preamble renames the caption for the Algorithm float to Listing, as desired:


However, the cross-reference label using the following command remains "Algorithm" (should be "Listing"):


Essentially, I am trying to rename Algorithm floats to Listing floats. (The book will have no algorithms.) LyX has Algorithm, Figure, and Table as floats to insert. If there was a way to configure and add Listing to the same menu (Insert >> Float >> Listing), that would also be a great solution.


The following failed:


The following eliminated the word "Algorithm" for the reference label altogether:


I have not yet looked into the babel package.


How can you rename "Algorithm" to "Listing" everywhere, including:

  • Caption
  • Label reference
  • In the front matter (i.e., List of Listings rather than List of Algorithms)


share|improve this question

3 Answers 3

up vote 6 down vote accepted


Do not mix lst: with Algorithm floats.

  1. Rename lst: to alg:.
  2. Change the preamble to:

This does not change the "List of Algorithms" to "List of Listings". The text is found in "":

    Type                  algorithm
    GuiName               Algorithm
    Placement             tbp
    Extension             loa
    NumberWithin          none
    Style                 ruled
    ListName              "List of Algorithms"
    LaTeXBuiltin          false

The improper way to fix this is:

  1. Edit
  2. Change "List of Algorithms" to "List of Listings".
  3. Click Tools >> Reconfigure.
  4. Restart LyX.

At this point, "List of Algorithms" will read "List of Listings".

share|improve this answer
When I inserted an algorithm float with this preamble, I got "LaTeX Error: Command \algorithmname already defined." unless I made the third line "\renewcommand{\algorithmname}{Listing}". It works now, although I wonder how to get the caption formatting to work like regular figure and table floats instead of the line above the listing. –  FvD Sep 16 '13 at 18:10

Fora separate doc add in Document > Settings > Local Layout:

    Type                  listing
    GuiName               Code Listing
    Placement             tbp
    Extension             lol
    NumberWithin          none
    Style                 ruled
    ListName              "List of Listings"
    LaTeXBuiltin          false

Then you can insert this with menu Insert > Float > Listing. This makes the choice document-specific and allows you to use both, rather than change the entire Lyx install.

share|improve this answer

I changed the List of Algorithms to List of Listings with:

    \listof{algorithm}{List of Listings} 
share|improve this answer

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.