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 am writing a document that does not required much formalisms, but I want to implement the following numbering system:

1 Section
Table 1: Caption
Figure 1: Caption
1.1 Subsection
Table 1.1: Caption
Figure 1.1: Caption

Any suggestion?

share|improve this question
1  
How should a second figure in "Section 1" be numbered? How a second figure in "Subsection 1.1"? –  lockstep Oct 2 '12 at 8:59
    
Good spotted. It would only work with one figure and one table per subsection. –  Alejo Oct 2 '12 at 9:02
    
Does your comment mean that the question is moot (in which case it will likely be closed)? If not, I suggest you elaborate on your (rather unusual) numbering scheme, specifying how floats in a second section or in a second subsection within the first section should be numbered. –  lockstep Oct 2 '12 at 9:09
    
Well, as I mentioned, my initial idea was about the problem restrained to one figure/one table per subsection. A very particular case. If it happens that the question is narrowed and moot, how could I close it? –  Alejo Oct 2 '12 at 14:15
add comment

1 Answer

up vote 5 down vote accepted

This appends b, c .. if there is more than one float in each section.

enter image description here

\documentclass{article}

\makeatletter
\@addtoreset{table}{subsection}
\@addtoreset{figure}{subsection}
\@addtoreset{table}{section}
\@addtoreset{figure}{section}


\renewcommand\thefigure{%
  \ifnum\value{subsection}=0 \thesection\else\thesubsection\fi\ifnum\value{figure}>1 \alph{figure}\fi}
\renewcommand\thetable{%
  \ifnum\value{subsection}=0 \thesection\else\thesubsection\fi\ifnum\value{table}>1 \alph{table}\fi}

\makeatother

\begin{document}

\listoftables

\section{zzz}

a
\begin{table}[!htp]TTTT\caption{tt}\end{table}

b
\begin{figure}[!htp]FFF\caption{ff}\end{figure}


\subsection{www}


a
\begin{table}[!htp]TTTT\caption{tt tt}\end{table}

b
\begin{figure}[!htp]FFF\caption{ff ff}\end{figure}

aa
\begin{table}[!htp]TTTT\caption{tt tt tt}\end{table}

bb
\begin{figure}[!htp]FFF\caption{ff ff ff}\end{figure}

\end{document}
share|improve this answer
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.