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

I'm working with platex (the Japanese latex compiler) and I'm trying to change the caption system for Listings and Figures. For both I would like the numbering to be based on section so if its a figure or Listing in section 2 I want it to be in the style of 2.1

Also I want to change the tag Listing to list.

The doctype I'm using is jarticle because its the only type I found that works with Japanese letters.

Any advice would be much appreciated.

An example of my current code is as follows


\caption{some caption}%

\lstset{numbers=left, stepnumber=5, caption={text}, escapeinside={\%*}{*)}, frame=single, tabsize=2}
code here

share|improve this question

migrated from stackoverflow.com May 24 '11 at 10:11

This question came from our site for professional and enthusiast programmers.

@Johan please do not change the question to add a solution. The answer is already visible below. – Caramdir May 26 '11 at 2:18

You may use the \@addtoreset{figure}{section} command in combination with \renewcommand{\thefigure}{\thesection.\arabic{figure}}. See this page.

To say something about changing the listing name it would be helpful to see which package you use to format them. Pleas create a minimal working example (MWE).

Here’s mine which shows everything you’ll need I think…



\renewcommand{\lstlistingname}{List}% [1]
\makeatletter% [2]
    \@addtoreset{lstlisting}{section}% [3]
\AtBeginDocument{% [4]

Content ...

Test ...

[1] Change the name of listings
[2] Necessary to use command containing @
[3] Lets the listing counter be resetted in a new section
[4] Necessary because \thelstlistings is undefined before begin document.
[5] Renew number layout.

As egreg said thers a second way with the chngcntr package, maybe one prefer this way …




Content ...

Test ...

\caption{A example}
share|improve this answer
One can simplify by loading chngcntr and saying only \counterwithin{lstlisting}{section} inside \AtBeginDocument (no \@addtoreset is needed, and \counterwithin automatically redefines \the...) – egreg May 24 '11 at 16:49
@egreg: Thank. I read it on the linked page in my solution after posting. I like the ways with no extra packages. I added an extra example. – Tobi May 24 '11 at 16:51
Why reinventing the wheel? :) It's unfortunate that the LaTeX kernel doesn't provide a user interface for linking counters; chngcntr is powerful and unobtrusive. – egreg May 24 '11 at 17:01
@egreg: I see, maybe I can remember the package in future … :-) – Tobi May 24 '11 at 18:09

Your Answer


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