
我知道圖和表格的組合清單?,但是那裡的提問者要求一數字和表格的編號方案,我不要。不幸的是,答案似乎取決於這個先決條件。
我的問題是關於預期的結果/輸出,例如:
圖片和表格清單
圖1:新奧爾良的樹木地圖.................................... ........... 3
圖2:每天落葉數....................... 5
表1:樹木種類....................................... .... ............ 12
圖 3:每 1000 片落葉空氣品質下降 ....... 20
為了實現這一點,按照上面連結中的建議將數字重新定義為表格(或相反的方式)(即類似的東西\let\figure\table\let\endtable\endfigure
)是行不通的,因為它當然會導致所有數字也被稱為「Table 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
相關指令是 as 'always' \addcontentsline
。
figure
並且標題被寫入副檔名為或 的table
檔案中。\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
是浮點數的名稱,即figure
or table
(通常)。可以使用和修補它,將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}