1

I am new to the forum. Hopefully my question is within standards.

I want to add the word “Figure”/"Table" in front of each caption in the lof/lot. I tried this solution: https://tex.stackexchange.com/a/155202/124927

And it worked perfectly. Well, almost.

The thing is that now the format in my lof/lot is slightly altered. It messes up the indentation in the captions that are long enough to require two lines, as in: enter image description here

I am aware of the package tocloft. The problem is that the simple fact of loading it (as [subfigure]{tocloft}) in turn messes up the formatting of the lof and lot. The formatting needs to be consistent in all of the thesis.

I am using a customized class (not report , etc.) for the formatting of my school (created by somebody some time ago) which starts like this:

\NeedsTeXFormat{LaTeX2e}[2009/09/24]
\ProvidesPackage{sgpPhDstyle}

Is there any way to keep the solution in https://tex.stackexchange.com/a/155202/124927, while keeping the formatting of the lof/lot? Maybe a clever re-definition of \listoffigures?

Thanks a lot in advance to anybody that can give me an answer.

EDIT2: Ok, here is a MWE:

    \documentclass{article}
    \usepackage{tocloft}
    \begin{document}
    {
    \let\oldnumberline\numberline
    \renewcommand{\numberline}{\figurename~\oldnumberline}
    \listoffigures
    }   
    \addcontentsline{toc}{chapter}{List Of Figures} 
    \cleardoublepage

    \begin{figure}[!ht]
    \caption{this is a really loooooooooooooooooooooooooong figure captionthat will take up two lines in the List of Figures.} 
    \end{figure}
    \end{document}
JCRodro
  • 11
  • Welcome to TeX.SX! Please add a MWE. – TeXnician Feb 09 '17 at 12:49
  • You can try to achieve a MWE by just transferring your document to article class, adding one figure with a long title and the \listoffigures command. Add as many lines of code as needed to reproduce the error and post that code. – TeXnician Feb 09 '17 at 13:46

1 Answers1

2

tocloft provides better ways to use such a figure prefix, but the best way is to use caption and defining a new caption list format for figure and table.

\documentclass{article}
\usepackage{caption}
\usepackage[nottoc]{tocbibind}
\usepackage{tocloft}
\addtolength{\cftfignumwidth}{30pt}% More space
\addtolength{\cfttabnumwidth}{30pt}% More space


\usepackage{pgffor}

\DeclareCaptionListFormat{figprefix}{#1\figurename~#2}
\DeclareCaptionListFormat{tabprefix}{#1\tablename~#2}

\begin{document}
\tableofcontents
\cleardoublepage
\listoffigures
\listoftables


\captionsetup[figure]{listformat=figprefix}
\captionsetup[table]{listformat=tabprefix}


\foreach \x in {1,...,10} {%
  \begin{figure}[!ht]
    \caption{this is a really loooooooooooooooooooooooooong figure caption that will take up two lines in the List of Tables.}
  \end{figure}

  \begin{table}[!ht]
    \caption{this is a really loooooooooooooooooooooooooong figure caption that will take up two lines in the List of Tables.} 
  \end{table}


}
\end{document}

enter image description here

  • Hi. In my actual code (with the class I mentioned, with which I can't really get a MWE), this solution does add the word "Figure"/"Table" but does not solve the indentation issue. In addition, it causes the word Figure"/"Table" to overlap the list entries. – JCRodro Feb 10 '17 at 02:08
  • I don't have your class at hand. It is possible to change the \cftfigindent etc. lenghts, but class templates glued together by people apparently without any understanding of LaTeX mess up the whole affair! –  Feb 10 '17 at 13:35