3

I have been preparing a .cls file modifying the article.cls. I need to customize the list of figure page of my document.

The list of figure part of my .cls file is as follows:

    \newcommand\listoffigures{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\listfigurename}%
        \thispagestyle{plain}
        \begin{flushright}
            {\bf\pagename}
        \end{flushright}
      \@mkboth{\MakeUppercase\listfigurename}%
              {\MakeUppercase\listfigurename}%
    \@starttoc{lof}%
    \if@restonecol\twocolumn\fi
    }
\newcommand*\l@figure{\@dottedtocline{1}{-4.9em}{4.9em}}

When I use the

\listoffigures

code to print the list of figure page, it produces it as follows:

1.1        Caption of Figure 1.1  .................. 12
1.2        Caption of Figure 1.2  .................. 17
2.1        Caption of Figure 2.1  .................. 25
2.2        Caption of Figure 2.2  .................. 26

But, the required list of figures page must be as follows:

Figure 1.1 Caption of Figure 1.1  .................. 12
Figure 1.2 Caption of Figure 1.2  .................. 17
Figure 2.1 Caption of Figure 2.1  .................. 25
Figure 2.2 Caption of Figure 2.2  .................. 26

For this, how can I modify the .cls file?

2
  • 2
    you have tagged your question with tocloft and then rejected an answer that uses it! – cmhughes Jun 8 '14 at 14:35
  • I do not think, that listoffigures is really the problem here, but rather the way how \caption writes the entry to the .lof file. One approach might be the usage of caption package. – user31729 Jun 8 '14 at 21:09
2

This is not a redefinition of \listoffigures but uses the facilities provided by the very sophisticated caption package by defining a figurenew listformat, with prefix Figure (as contained \figurename) and a slight redefinition of \l@figure which must be changed to \newcommand{\l@figure} in the class file, if no \LoadClass{article} is used.

\documentclass[12pt]{article}
\usepackage[demo]{graphicx}%

\usepackage{caption}

\makeatletter
\renewcommand*\l@figure{\@dottedtocline{1}{0em}{7em}}
\makeatother

\DeclareCaptionListFormat{figurenew}{\textbf{\figurename}~#1 #2}%
\captionsetup{listformat=figurenew}

\renewcommand{\thefigure}{\arabic{section}.\arabic{figure}}
\begin{document}
\listoffigures
\clearpage
\section{first}


\begin{figure}
\includegraphics[width=5cm,height=3cm]{somefig}%
\caption{Some caption number one}
\end{figure}

\begin{figure}
\includegraphics[width=5cm,height=3cm]{somefig}%
\caption{Some caption number one}
\end{figure}

\setcounter{section}{99}

\section{Hundred}

\begin{figure}
\includegraphics[width=5cm,height=3cm]{somefig}%
\caption{Some caption number three}
\end{figure}


\end{document}

enter image description here

1
\listfiles
\documentclass{report}
\def\pagename{Page}
\makeatletter
   \renewcommand\listoffigures{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\listfigurename}%
        \thispagestyle{plain}
        \begin{flushright}
            {\bf\pagename}
        \end{flushright}
      \@mkboth{\MakeUppercase\listfigurename}%
              {\MakeUppercase\listfigurename}%
    \@starttoc{lof}%
    \if@restonecol\twocolumn\fi
    }
\renewcommand*\l@figure{\@dottedtocline{1}{-4.9em}{4.9em}}
\long\def\@caption#1[#2]#3{%
  \par
  \addcontentsline{\csname ext@#1\endcsname}{#1}%
    {\protect\numberline{Figure \csname the#1\endcsname}{\ignorespaces #2}}%
  \begingroup
    \@parboxrestore
    \if@minipage
      \@setminipage
    \fi
    \normalsize
    \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
  \endgroup}
\makeatother

\begin{document}
\chapter{foo}
\begin{figure}
foo\caption{bar}
\end{figure}
\listoffigures

\end{document}

enter image description here

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.