自定义图形列表中自定义浮动环境条目的格式前缀

自定义图形列表中自定义浮动环境条目的格式前缀

我正在处理一份基于report类别的复杂格式的文档。

\DeclareFloatingEnvironment我使用基于的newfloat包定义了一个新的照片图片列表这个答案。我使用基于的包\DeclareTOCStyleEntry自定义了图形列表中条目的前缀tocbasic这个答案。我得到了这个结果:

在此处输入图片描述

问题是,照片列表还是数字。我尝试过许多论坛上的许多解决方案,但都不起作用。我无法更改类或包,因为它会破坏格式并产生问题。例如,这个答案scrreprt我无法使用。我还尝试了基于\newfloat以下float包(在最后的脚本中注释掉)这个答案但我无法在条目中添加前缀(照片)照片列表也不自定义它,它只显示数字,而不是数字/照片。我也尝试使用\DeclareTOCStyleEntry但是photograph它会产生错误:

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.

我使用了\DeclareFloatingEnvironmentafter,\DeclareTOCStyleEntry因为\DeclareFloatingEnvironment内部使用,\listoffigures因此在 toc 样式条目之后声明它会继承格式。在 toc 样式条目上方声明它不会显示前缀。

我需要的结果是这样的:

在此处输入图片描述

此处附有简化版的 latex 脚本。有什么方法可以更改前缀数字照片在里面照片列表

\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}

答案1

此代码使用该包tocloft来设置两个列表。

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}

相关内容