2

To list my figures, I used \listoffigures and the result looks like

1.1 xyza ......... 12
1.2 abc2 ......... 14
2.1 bacd ......... 17
2.2 bace ......... 18
.
.
.
6.1 xxxx ......... 40

However, I am trying to list my figures like

Figure 1 xyza ......... 12
Figure 2 abc2 ......... 14
Figure 3 bacd ......... 17
Figure 4 bace ......... 18
.
.
Figure n xxxx ......... 40

For this I tried the following:

\usepackage{tocloft}
\renewcommand{\cftfigfont}{Figure }

This adds ‘Figure ’ before 1.1, 1.2 2.1, 2.2, . . ., 6.1. To change (1.1, 1.2, 2.1, 2.2, . . ., 6.1) to (1, 2, 3, . . ., n) in the list of figures, I tried using

\renewcommand{\thefigure}{\arabic{figure}.}

and it do changes to 1, 2, 3, . . . But the numbering 1, 2, 3, . . . again starts when a new chapter starts and moreover the entries in the figure caption also changes which I don't want. So, how to get a continuous figure number, irrespective of chapter in the list of figures and without any changes in the figure caption.

  • Continuous v. per-chapter/section numbering of figures, tables, and other document elements sounds like it might solve the same problem - figure labelling not resetting on a new chapter. How do you want Figures to be labelled where they appear in the chapter, also as Fig. 1, Fig. 2, ..., Fig. N or is the change you want specific to the list of figures? – Dai Bowen Sep 12 '16 at 10:50
  • I want changes only in the list of figures. In the chapters, where the figures are like Figure 1.2, Figure 2.3 and so on, I don't want any changes. – user48319 Sep 12 '16 at 10:55
  • Ok, not a duplicate then - so what you want is to have the LoF ignore the number assigned to the figure and present a new figure. At a guess you might need to split the figure environment such that it increments two counters - one for the label in captions and one for a new list of things (which I think tocloft can do. – Dai Bowen Sep 12 '16 at 11:07
  • If the numbers in the LoF are 1.2, 2.3 and 4.6 etc, I wonder what happened to figure 1.1, 2.1, 2.2 etc? Isn't this numbering scheme confusing? – user31729 Sep 12 '16 at 12:48
  • yes, you are right. They are also there. I just picked few samples. I am editing the question for consistency. – user48319 Sep 12 '16 at 13:38
1

The macro \mycaption uses \thefigure for captions and \arabic{figure} for the lof (plus a few other formatting changes). Note that \@captype can be figure or table.

\documentclass{article}
\usepackage{caption}% required

\makeatletter
\newcommand{\mycaption}[2][\@empty]% #1 = short caption (optionl), #2 = caption
{\refstepcounter\@captype
 \caption@caption*{\csname fnum@\@captype\endcsname{: }#2}%
 \ifx\@empty#1
   \addcontentsline{\csname ext@\@captype\endcsname}{\@captype}%
     {\csname\@captype name\endcsname\space\arabic{\@captype}: #2}%
 \else
   \addcontentsline{\csname ext@\@captype\endcsname}{\@captype}%
     {\csname\@captype name\endcsname\space\arabic{\@captype}: #1}%
 \fi
}
\makeatother

\begin{document}

\listoffigures

\begin{figure}
\renewcommand{\thefigure}{1.1}%
\caption{normal caption}

\renewcommand{\thefigure}{2.6}%
\mycaption{my caption}
\end{figure}

\end{document}

demo


If you don't want to rename all your \captions to \mycaption, just use

\let\caption=\mycaption

instead. However, \caption* will no longer work.


Odds are the figure counter is being reset to 0 at the start of each chapter, in which case you will need to use a different counter.

\newcounter{myfigure}
\newcounter{mytable}

\makeatletter
\newcommand{\mycaption}[2][\@empty]% #1 = short caption (optionl), #2 = caption
{\refstepcounter\@captype
 \caption@caption*{\csname fnum@\@captype\endcsname{: }#2}%
 \stepcounter{my\@captype}%
 \ifx\@empty#1
   \addcontentsline{\csname ext@\@captype\endcsname}{\@captype}%
     {\csname\@captype name\endcsname\space\arabic{my\@captype}: #2}%
 \else
   \addcontentsline{\csname ext@\@captype\endcsname}{\@captype}%
     {\csname\@captype name\endcsname\space\arabic{my\@captype}: #1}%
 \fi
}
\makeatother

Finally, I despise this programming style, as it is almost unreadable. So for my own peace of mind:

\makeatletter
\def\mycaption{\csname\@captype @caption\endcsname}

\newcommand{\figure@caption}[2][\@empty]% #1 = short caption(optional), #2 = caption
{\refstepcounter{figure}%
 \caption@caption*{\fnum@figure{: }#2}%
 \stepcounter{myfigure}%
 \ifx\@empty#1
   \addcontentsline{lof}{figure}{\figurename\space\arabic{myfigure}: #2}%
 \else
   \addcontentsline{lof}{figure}{\figurename\space\arabic{myfigure}: #1}%
 \fi
}
\newcommand{\table@caption}[2][\@empty]% #1 = short caption(optional), #2 = caption
{\refstepcounter{table}%
 \caption@caption*{\fnum@table{: }#2}%
 \stepcounter{mytable}%
 \ifx\@empty#1
   \addcontentsline{lot}{table}{\tablename\space\arabic{mytable}: #2}%
 \else
   \addcontentsline{lot}{table}{\tablename\space\arabic{mytable}: #1}%
 \fi
}
\makeatother
  • Will this play nicely with the likes of subcaption and subfig? – Dai Bowen Sep 12 '16 at 15:30
  • 1
    If you don't want your subfigure captions to show up in the lof, no problem. Otherwise, you probably will need a new \subcaption as well. (I wonder what \@captype is in a subfigure? Hmmm) – John Kormylo Sep 12 '16 at 15:37

Your Answer

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