0

I have couple of images in every chapter and I need to specify a figure number for every image depending on the chapter and it must get automatically reflected in the list of figures section. How do I achieve this? Please help!

  • Welcome to TeX.SX! Usually, this is something that is done automatically with \listoffigures, depending on the class however. Please provide a minimal working document with \documentclass and \begin{document}...\end{document} – user31729 Apr 17 '16 at 16:01
  • Use \begin{figure}...\caption{figure description}\end{figure} and \counterwithin{figure}{chapter} (requires chngcntr package), if the figure counter isn't in the chapter counter reset list (but this is a standard, actually, at least for book class) – user31729 Apr 17 '16 at 16:06
1
\documentclass{book}


\begin{document}
\tableofcontents
\listoffigures


\chapter{First}

\begin{figure}
\caption{First figure from chapter \thechapter}

\caption{Second figure from chapter \thechapter}
\end{figure}

\chapter{Second Chapter}

\begin{figure}
\caption{First figure from chapter \thechapter}

\caption{Second figure from chapter \thechapter}
\end{figure}



\end{document}
  • Hi! Thanks a ton for the response. But I have some clarification in my code. Please help \chapter{chap1} \section{chap1section1} \begin{figure} \centering \includegraphics[scale=0.5]{img1.png} \caption{cap1} \end{figure} and couple of other images too... \section{chap1sec2} But when I compile the code only the first image is placed under the section 1 as it is of figure 1.1 and all other images are placed after section 2 because they have captions 1.2,... and so on. All I did was include the images under section1. Kindly help... – Guru Apr 17 '16 at 18:40
  • @Guru: That's the floating mechanism of LaTeX, this has nothing to do with your first question. If you don't floating figures, use \includegraphics{...} \captionof{figure}{cap1} etc. You need the caption package then – user31729 Apr 17 '16 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.