Take the 2-minute tour ×
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.

I recently stepped out of my comfort bounds and decided to add some Code snippets to my paper. I was able to get everything working fine and looking good, except the actual title. Everything else in my Document uses arabic, i.e. Figure 2.3, Table 4.5, etc... for some reason when I insert the Code (Using lstlisting), the published version becomes "Listing III.1: code title".

I tried using the same setup in my pre-amble as the figures, tables, and equations:

    \renewcommand\lstlistingname{\arabic{chapter}.\arabic{lstnumber}}

However, that removes the "Listing" portion and instead gives me "3.1 III.1: code title". Obviously I am not wise enough with the \renewcommand? or is there another setting I should be changing?

Here is the pre-amble I was trying to copy:

\newcommand{\updateCounters}{\renewcommand{\thefigure}{\arabic{chapter}.\arabic{figure}}%
\renewcommand{\thetable}{\arabic{chapter}.\arabic{table}}%
\renewcommand{\theequation}{\arabic{chapter}.\arabic{equation}}%

Thanks!

share|improve this question
    
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. –  Jubobs Mar 5 at 11:06
add comment

1 Answer 1

up vote 3 down vote accepted

a complete example makes it easier to help!

\documentclass[openany]{book}
\usepackage{listings}
\AtBeginDocument{%
  \renewcommand\lstlistingname{My Listing}
  \renewcommand\thelstlisting{\thesection.\arabic{lstlisting}}}

\begin{document}

\lstlistoflistings

\chapter{dummy}
\section{More dummy}

\begin{lstlisting}[caption=bar]
 foo
\end{lstlisting}

\end{document}

Herbert

share|improve this answer
    
Wow, I guess I DO need to learn how to use renewcommand. I will start looking for a tutorial post haste. Thanks for the help, worked like a charm. –  Mike Dec 19 '10 at 15:43
1  
@Mike: You should mark Herbert's answer as accepted by clicking on the outline of the checkmark next to his answer. –  TH. Mar 13 '11 at 20:51
add comment

Your Answer

 
discard

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.