![從目錄中刪除 [newfloat] 列表](https://rvso.com/image/290208/%E5%BE%9E%E7%9B%AE%E9%8C%84%E4%B8%AD%E5%88%AA%E9%99%A4%20%5Bnewfloat%5D%20%E5%88%97%E8%A1%A8.png)
我正在使用 newfloat 包,並且添加了一個新數字:
\DeclareFloatingEnvironment{dirfigure}
現在,當我使用\listofdirfigures
- 時,列表將添加到目錄中。
對於正常的數字,我可以使用\listoffigures*
(with *
) 不將其列在目錄中,但是\listofdirfigures*
不起作用。
如何不在目錄中列出 Dirfigures 清單?
最小的例子:
\documentclass[a4paper,twoside]{memoir}
\usepackage{newfloat}
\DeclareFloatingEnvironment{dirfigure}
\begin{document}
\tableofcontents*
\listoffigures*
\listofdirfigures
\chapter{bah}
\begin{dirfigure}
bah
\caption{bah}
\end{dirfigure}
\begin{figure}
bah
\caption{bah}
\end{figure}
\end{document}
謝謝
答案1
供參考,memoir
唯一的方法:
\documentclass[a4paper,twoside]{memoir}
\newfloat[chapter]{dirfigure}{dirf}{Dirfigure}
\newlistof{listofdirfigures}{dirf}{List of Dirfigures}
\newlistentry[chapter]{dirfigure}{dirf}{0}
\cftsetindents{dirfigure}{0em}{2.3em}
\begin{document}
\tableofcontents*
\listoffigures*
\listofdirfigures*
\chapter{bah}
\begin{dirfigure}
bah
\caption{bah}
\end{dirfigure}
\begin{figure}
bah
\caption{bah}
\end{figure}
\end{document}
答案2
如果您想使用 來執行此操作\newfloat
,可以透過以下方法獲得與 的清單列印巨集相同的功能memoir
:
\documentclass[a4paper,twoside]{memoir}
\usepackage{etoolbox}
\usepackage{newfloat}
\makeatletter
%% we define a helper macro for adjusting lists of new floats to
%% accept a * behind them for not being shown in the TOC, like
%% the other list printing commands in memoir
\newcommand{\AdjustForMemoir}[1]{%
\csletcs{kept@listof#1}{listof#1}%
\csdef{listof#1}{%
\@ifstar
{\csappto{newfloat@listof#1@hook}{\append@star}%
\csuse{kept@listof#1}}%
{\csuse{kept@listof#1}}%
}
}
\def\append@star#1{#1*}
\makeatother
\DeclareFloatingEnvironment{dirfigure}
\AdjustForMemoir{dirfigure} % prepare `\listofdirfigures` so it accepts a *
\begin{document}
\tableofcontents*
\listoffigures*
\listofdirfigures*
\chapter{bah}
\begin{dirfigure}
bah
\caption{bah}
\end{dirfigure}
\begin{figure}
bah
\caption{bah}
\end{figure}
\end{document}
如果您\listofdirfigures
在不使用 的情況下使用*
,該清單將進入目錄。
\listofdirfigures
這是透過利用呼叫時執行的最後一個命令是(在一組中)這一事實來實現的
\newfloat@listofdirfigure@hook\listoffigures
但該newfloat
軟體包會小心地重新定義事物,以便\listoffigures
做正確的事情。鉤子通常是空的,但它無關緊要。我重新定義\listofdirfigures
(或者更好的是,稱為 的替代版本\listofdirfigure
)來尋找以下*
;在這種情況下,我附加\append@star
到鉤子,所以 TeX 最終會看到
\append@star\listoffigures
萬一被\listofdirfigures*
調用;這將成為\listoffigures*
所希望的。如果沒有*
出現,則沒有任何改變。
我提供了一個\AdjustForMemoir
宏,以便每個新的浮動清單製作命令都可以以這種方式進行修改。
答案3
透過提交修復https://gitlab.com/axelsommerfeldt/caption/commit/5584091f13a4d63c5245b4d8b0e9ac0171c85436
今天我會向CTAN推送新版本的「字幕包捆綁包」;同時請使用https://gitlab.com/axelsommerfeldt/caption/raw/master/tex/newfloat.sty作為舊的 newfloat.sty 的替代品。
順便說一句:請向我報告此類問題/代碼,以便我有機會及時修復它。 (我花了5年才偶然發現這個問題。)