Custom caption prefix

3.6k views Asked by At

When using:

\begin{listing}
...
\caption{foo}
\end{listing}

The caption will say: Listing x: foo. How can I replace the word Listing with something else?

2

There are 2 answers

2
JohnB On

You might want to read the manual

http://mirror.switch.ch/ftp/mirror/tex/macros/latex/contrib/listings/listings.pdf

page 32

\begin{listing}[caption=Some fancy listing]

or try

\begin{listing}[title=Some fancy listing]

or try

\renewcommand{\lstlistingname}{A funny listing}

Minimal example that works for me:

\documentclass{article}

\usepackage{listings}
\renewcommand{\lstlistingname}{Something}

\begin{document}
Some text.
\begin{lstlisting}[caption=wwww]
xxxx
\end{lstlisting}
Some more text.
\end{document}
1
Guillaume Algis On

If you are using minted (I am, and my source looks like yours), you may want to try

\renewcommand{\listingscaption}{Some fancy listing}