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)


3 Answers 3



Do not mix lst: with Algorithm floats. The previous solution used \newcommand{\algorithmname}{Listing}, but this could result in LaTeX Error: Command \algorithmname already defined. Instead, apply the following changes:

  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 "stdfloats.inc":

    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 stdfloats.inc.
  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".


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.


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

    \listof{algorithm}{List of Listings} 

You must log in to answer this question.

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