图表目录

图表目录

我知道图表的合并列表?,但提问者要求图表的编号方案,我不想要。不幸的是,答案似乎取决于这个先决条件。

我的问题是关于预期结果/输出,例如:


图表目录

图 1:新奥尔良树木地图 ...................................................... 3

图2:每天落叶数量................................... 5

表 1:树木种类 ................................................................ 12

图 3:每落1000片树叶造成的空气质量下降 ...................... 20


为了使其起作用,按照上面的链接中的建议将图形重新定义为表格(或反之亦然)(类似于\let\figure\table\let\endtable\endfigure)不起作用,因为它当然也会导致所有图形也被称为“表格 x”...

答案1

这有效。代码注释得很好,所以我认为不需要再添加注释。

在此处输入图片描述

\documentclass{article}

% To make the page shorter
\pagestyle{empty}
\textheight3in

% CODE STARTS HERE
% Based on `tocloft` package
\usepackage[titles]{tocloft}
\newlistof{figtab}{loft}{List of Figures and Tables}
\makeatletter
% Change the file extension of both lot and lof
\def\ext@figure{loft}
\def\ext@table{loft}
% Store the original `\thefigure` and `\thetable`
\let\tohe@thefigure\thefigure
\let\tohe@thetable\thetable
% Redefine them to contain a "dummy" `\tohe@list...`
\def\thefigure{\tohe@listfig\tohe@thefigure}
\def\thetable{\tohe@listtab\tohe@thetable}
% Make the two dummy commands truly dummy
\let\tohe@listfig\relax
\let\tohe@listtab\relax
% Store the original `\listoffigtab`
\let\tohe@listoffigtab\listoffigtab
% Redefine it in such a way that the dummy commands insert "Fig." or "Tab." respectively
\def\listoffigtab{%
  \begingroup
  \def\tohe@listfig{Fig.~}
  \def\tohe@listtab{Tab.~}
  \tohe@listoffigtab
  \endgroup  
}
% Change \listoffigtab spacing
\setlength{\cftfignumwidth}{5em}
\setlength{\cfttabnumwidth}{5em}
\setlength{\cftfigindent}{0pt}
\setlength{\cfttabindent}{0pt}
\makeatother
% CODE ENDS HERE

\begin{document}

\listoffigtab

% !b just to make the floats appear on the bottom of the first page
\begin{figure}[!b]
\caption{First}
\end{figure}

\begin{table}[!b]
\caption{Little Table}
\end{table}

\begin{figure}[!b]
\caption{Second}
\end{figure}

\end{document}

答案2

相关命令是,如‘总是’ \addcontentsline

figuretable字幕被写入扩展名存储在\ext@figure或的文件中\ext@table

\@caption(实际上是内部处理器宏)中我们发现:

\long\def\@caption#1[#2]#3{%
  \par
  \addcontentsline{\csname ext@#1\endcsname}{#1}%
    {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
  \begingroup
    \@parboxrestore
    \if@minipage
      \@setminipage
    \fi
    \normalsize
    \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
  \endgroup}

的第一个参数\@caption是浮点数的名称,即figuretable(通常)。可以使用并修补它,抓取table字幕并将redirect其保存到扩展名为 的文件中\ext@figure

\documentclass{book}

\usepackage{caption}
\usepackage{xstring}
\usepackage{xpatch}

\makeatletter
\xpatchcmd{\@caption}{%
  \addcontentsline{\csname ext@#1\endcsname}{#1}%
  {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
}{%
  \IfStrEq{#1}{table}{% Filter `table` out
    \addcontentsline{\csname ext@figure\endcsname}{table}%
    {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
  }{%
    \addcontentsline{\csname ext@#1\endcsname}{#1}%
    {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
  }%
}{\typeout{Patch success}}{}
\makeatother

\renewcommand{\listfigurename}{List of Figures and Tables}

\begin{document}
\listoffigures
\begin{figure}
\caption{first figure}
\end{figure}

\begin{figure}
\caption{Another first figure}
\end{figure}


\begin{table}
\caption{first table}
\end{table}

\chapter{Another chapter}
\begin{table}
\caption{Yet another table}
\end{table}

\end{document}

在此处输入图片描述

yo'正确注意到不清楚 LOFT 中它是表格还是图形后进行了一个小更新:

\documentclass{book}

\usepackage{caption}
\usepackage{xstring}
\usepackage{tocloft}
\usepackage{xpatch}

\addtolength{\cftfignumwidth}{30pt}
\addtolength{\cfttabnumwidth}{30pt}
% Prepend the tab or fig number with a `\makebox` (for equal width) and put `Tab.` or `Fig.` in there. Change the names at will 
\renewcommand{\cfttabpresnum}{\makebox[30pt][l]{Tab.}}  
\renewcommand{\cftfigpresnum}{\makebox[30pt][l]{Fig.}}  


\makeatletter
\xpatchcmd{\@caption}{%
  \addcontentsline{\csname ext@#1\endcsname}{#1}%
  {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
}{%
  \IfStrEq{#1}{table}{%
    \addcontentsline{\csname ext@figure\endcsname}{table}%
    {\protect\numberline{\csname the#1\endcsname\hfill\hspace{1em}}{\ignorespaces #2}}%
  }{%
    \IfStrEq{#1}{figure}{%
      \addcontentsline{\csname ext@#1\endcsname}{#1}%
      {\protect\numberline{\csname the#1\endcsname\hfill\hspace{1em}}{\ignorespaces #2}}%
    }{%
     \addcontentsline{\csname ext@#1\endcsname}{#1}%
     {\protect\numberline{\csname the#1\endcsname}{ \ignorespaces #2}}%
    }
  }%
}{\typeout{Patch success}}{}
\makeatother

\renewcommand{\listfigurename}{List of Figures and Tables}

\begin{document}
\listoffigures
\begin{figure}
\caption{first figure}
\end{figure}

\begin{figure}
\caption{Another first figure}
\end{figure}


\begin{table}
\caption{first table}
\end{table}

\chapter{Another chapter}
\begin{table}
\caption{Yet another table}
\end{table}

\section{First section}
\subsection{First subsection}
\subsubsection{First subsubsection}
\begin{table}
\caption{Yet another another table}
\end{table}


\end{document}

在此处输入图片描述

相关内容