[texhax] Counters for tables

Lantz Susan lantzs at tristate.edu
Fri Apr 25 20:23:20 CEST 2008


Having recently just created new environments to distinguish maps and
plates from figures, it seems to me that it would be lot simpler for you
to create a new table environment (for the listings, for instance), but
have the new environment use the same counter that your table
environment uses. Or, to use two different counters and set them equal
every time one of the environments is called, advance the counter you
just used, then (again) set them equal to each other.

Also, you might check if your documentclass supports the \numberwithin
command. For example, with amsbook:

\numberwithin{equation}{chapter} (or section or whatever you choose)

If you created two new environments---one for figures and one for
listings---then if you decide to add a table at the last minute, you
won't have to redefine everything.


Susan A. Lantz, Ph.D.
Associate Professor of Mechanical Engineering
Tri-State University
lantzs at tristate.edu

-----Original Message-----

Message: 6
Date: Thu, 24 Apr 2008 19:16:16 +0100
From: "James Smith" <james.smith at aleph-one.com>
Subject: [texhax] Counters for tables
To: <texhax at tug.org>
Message-ID: <000001c8a637$49b219c0$0300000a at flaptop>
Content-Type: text/plain;	charset="us-ascii"


I have used the table environment for both figures and pseudo-code
listings, so I've had to redefine the captions to read `Figure x.x:...'
and `Listing x.x:...' depending on the context. This I managed easily,
but of course the figures and listings were numbered, say...

Figure 1.1
Listing 1.2
Listing 1.3
Figure 1.4

...instead of:

Figure 1.1
Listing 1.1
Listing 1.2
Figure 1.2

I thought the smartref package would allow me to overcome this without
much programming, maybe I've got the wrong end of the stick, but I've
still had to define separate environments for the tables, incrementing
the counters ``manually'' myself:








I call the \resettablecounters command in my custom \chapter command to
reset the counters. I've then had to define dedicated ref commands...




...and redefine the captions...



    \caption{Listing \thechapter.\thepseudoctr: \it#1}%

    \caption{Figure \thechapter.\thefigurectr: \it#1}%


Have a made a meal of this? I accept that I can practically halve the
number of newly created commands and environments by passing a second
argument to differentiate between the pseudo-code listings and figures
but before I attempt this I want to know whether I'm barking up the
wrong tree...

Any help would be greatly appreciated.

Kind regards,


More information about the texhax mailing list