GeneralCounters inside figure environment

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
greg
Posts: 2
Joined: Wed Nov 11, 2009 6:22 pm

Counters inside figure environment

Post by greg »

Hi,

I'm having problems with using counters inside figure environment. I have a counter deifned as:

Code: Select all

\newcounter{subfig}
\newcommand{\subfigcounterlabel}[1]{\textbf{\alph{#1}, }}
\newcommand{\newsubfig}{\refstepcounter{subfig}\subfigcounterlabel{subfig}}
and this works if used outside the figure environment (produces a, b, c,... sequence).

However, if \newsubfig is used inside the figure environment, I get an error:

Missing \endcsname inserted.
<to be read again>
\csname\endcsname

I don't quite understand \csname and where it should be placed; i've tried playing around with it a bit, but unsuccessfully.

Any help would be greatly appreciated!

Thanks,
Greg

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Counters inside figure environment

Post by localghost »

For sub-figures there exist several packages. The latter one isn't maintained any more and cause problems.


Best regards and welcome to the board
Thorsten¹
greg
Posts: 2
Joined: Wed Nov 11, 2009 6:22 pm

Re: Counters inside figure environment

Post by greg »

Hi Thorsten,

Thanks a lot for the swift reply! However, I think I was too vague in my initial post on what I need to do. I have a single .eps figure, with a single caption. The only thing is that I need to have a counter inside of that figure caption to account for the numbering in the figure. I can do it manually but I thought having a counter to do it would be a neater thing to do. The counter name I use is just by accident the same as the subfig package.

I've looked a bit into the packages you recommended, but it seems to me they deal with more elaborate stuff, like having several different figures under one caption etc. Or am I missing something?

Best,
Greg
Post Reply