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'm a heavy LaTeX user, but have very lite idea how the Tex programming is done. I'm writing a longer document and wanted to have figure numbers like that: chaper.section.figure_number e.g. Figure 4.3.10. After some goggeling i found this solution which works just fine:

\makeatletter
\@addtoreset{equation}{section}
\@addtoreset{figure}{section}
\@addtoreset{table}{section}
\def\thefigure{\thesection.\@arabic\c@figure}
\def\thetable{\thesection.\@arabic\c@table}
\def\theequation{\thesection.\@arabic\c@equation}
\makeatother

,although I have no Idea why. When I'm using a subfigure with a label unfortunately I get references like that: chaper.figure_nuber e.g. 4.30(a). But what i want is: chapter.section.figure_number.(a,,b,c..) e.g. 4.2.10(a). I guess I have to define an additional command like above, but from the subfig documentation I can't say which and how...

I would appreciate any help

share|improve this question

1 Answer 1

The following setup should to the job you're after. Note that I use the newer subcaption package instead of the older subfig package and that I make use of the \numberwithin command provided by the amsmath package.

\documentclass{book}
\usepackage{amsmath,    % for \numberwithin and \eqref commands
            subcaption} % for subfigure environment
\usepackage[demo]{graphicx} % remove 'demo' option for real document
\numberwithin{equation}{section}
\numberwithin{figure}{section}
\numberwithin{table}{section}

\begin{document}
\chapter{First Chapter}
\section{New ideas}

\begin{figure}[h]
\begin{subfigure}{0.45\textwidth}
\includegraphics[width=\columnwidth]{somegraph.pdf}
\caption{First subfig} \label{fig:1a}
\end{subfigure}
\hspace{\fill} % maximize horizontal separation of subfigs
\begin{subfigure}{0.45\textwidth}
\includegraphics[width=\columnwidth]{anothergraph.pdf}
\caption{First subfig} \label{fig:1b}
\end{subfigure}
\caption{The first figure}
\end{figure}

A display-style equation:
\begin{equation}\label{eq:1}
a^2+b^2=c^2
\end{equation}

And here are cross-references to subfigures \ref{fig:1a} and \ref{fig:1b} 
as well as to equation~\eqref{eq:1}.
\end{document}

enter image description here

share|improve this answer
    
Thank's for your answer. I would rather continue to use the subfigure package since I already have a lot of them in my document... But if there is no other way i will switch to your solution... –  Andre Aug 21 '12 at 6:46

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.