0

I am working on a document with complex formatting based on report class.

I defined a new List of Figures for Photographs using \DeclareFloatingEnvironment from newfloat package based on this answer. I customized the prefix of the entry in the list of figures using \DeclareTOCStyleEntry from tocbasic package based on this answer. I got this result:

enter image description here

The problem is, the prefix in the List of Photographs is still Figure. I have tried a lot of solutions on many forums but none of them worked. I cannot change the class or packages because it breaks the formatting and create problems. For example, this answer uses scrreprt which I cannot use. I also tried \newfloat from float package (commented out in the script at the end) based on this answer but I could neither add prefix (Photograph) in the entry in the List of Photographs nor customize it, it only shows the number and not the Figure/Photograph. I also tried to use \DeclareTOCStyleEntry for photograph but it generates errors:

Package tocbasic Error: toc style `tocline' needs toc style level.
Package tocbasic Error: toc style `tocline' needs toc entry level.
Package tocbasic Error: toc style `tocline' needs entry indent.
Package tocbasic Error: toc style `tocline' needs entry number width.

I used \DeclareFloatingEnvironment after \DeclareTOCStyleEntry because \DeclareFloatingEnvironment internally uses \listoffigures so declaring it after toc style entry inherits the formatting. Declaring it above toc style entry doesn't show the prefix.

The result I need is this:

enter image description here

The simplified version of latex script is attached here. Is there any way I can change the prefix Figure to Photograph in the List of Photographs?

\documentclass[12pt,a4paper]{report}
\usepackage{graphicx}
\usepackage{caption}

\usepackage{tocbasic} \DeclareTOCStyleEntry[ entrynumberformat=\figureentryformat{\figurename}, dynnumwidth, numsep=1em ]{tocline}{figure} \newcommand\figureentryformat[2]{\textbf{#1\enspace#2.}\hfill}

\usepackage{newfloat} \DeclareFloatingEnvironment[ fileext=lop, listname={List of Photographs}, name=Photograph, placement=tp, within=chapter, chapterlistsgaps=on, ]{photograph}

%\usepackage{float} %\newfloat{photograph}{tbp}{lop}[chapter] %\floatname{photograph}{Photograph} %\newcommand{\listofphotograpsname}{List of Photographs} %\newcommand{\listofphotographs}{% % \addcontentsline{toc}{chapter}{\listofphotograpsname} % \listof{photograph}{\listofphotograpsname} %}

\begin{document}

\tableofcontents \listoffigures \begingroup \let\clearpage\relax \listofphotographs \endgroup

\chapter{First chapter} \begin{figure} \includegraphics[width=\textwidth]{example-image} \caption{First dummy figure} \end{figure} \begin{figure} \includegraphics[width=\textwidth]{example-image} \caption{Second dummy figure} \end{figure}

\chapter{Second chapter} \begin{photograph} \includegraphics[width=\textwidth]{example-image} \caption{First dummy photo} \end{photograph} \begin{photograph} \includegraphics[width=\textwidth]{example-image} \caption{Second dummy photo} \end{photograph}

\end{document}

Simon Dispa
  • 39,141
Raja Ayaz
  • 133
  • 1
  • 3
  • 10

1 Answers1

1

This code uses the package tocloft to setup the two lists.

d

\documentclass[12pt,a4paper]{report}
\usepackage{graphicx}
\usepackage{caption}

\usepackage{newfloat} \usepackage{tocloft} % added <<<<<<<<<<

\newlistof{photograph}{lop}{List of Photograph}% <<<<<<<<<<<<<<<

\DeclareFloatingEnvironment[ fileext=lop, listname={List of Photographs}, %name=Photograph, placement=tp, within=chapter, chapterlistsgaps=on, ]{photograph}

\renewcommand{\cftfigpresnum}{\bfseries Figure~} % List of FIgures set up <<<<<<<< \setlength{\cftfignumwidth}{5ex} \setlength{\cftfigindent}{0ex} \newlength{\figlen}% a pre figure title length \settowidth{\figlen}{\bfseries\cftfigpresnum} % the word Figure~ \addtolength{\figlen}{\cftfignumwidth} \renewcommand{\cftfignumwidth}{\figlen} \renewcommand{\cftfigaftersnum}{.}

\renewcommand{\cftphotographpresnum}{\bfseries Photograph~} % List of Photograph set up <<<<<<<<<<<<<<<< \setlength{\cftphotographnumwidth}{5ex} \setlength{\cftphotographindent}{0ex} \newlength{\photographlen}% a pre photo title length \settowidth{\photographlen}{\bfseries\cftphotographpresnum} % the word Photograph~ \addtolength{\photographlen}{\cftphotographnumwidth} \renewcommand{\cftphotographnumwidth}{\photographlen} \renewcommand{\cftphotographaftersnum}{.}

\begin{document}
\tableofcontents \clearpage \listoffigures
\listofphotographs

\chapter{First chapter}
\begin{figure}
    \includegraphics[width=\textwidth]{example-image}
    \caption{First dummy figure}
\end{figure}
\begin{figure}
    \includegraphics[width=\textwidth]{example-image}
    \caption{Second dummy figure}
\end{figure}

\chapter{Second chapter}
\begin{photograph}
    \includegraphics[width=\textwidth]{example-image}
    \caption{First dummy photo}
\end{photograph}
\begin{photograph}
    \includegraphics[width=\textwidth]{example-image}
    \caption{Second dummy photo}
\end{photograph}

\end{document}

Simon Dispa
  • 39,141