Remove List of [newfloat] from TOC
If you want to do it with \newfloat
, here's a way for getting the same functionality of the list printing macros of 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}
If you use \listofdirfigures
without the *
, the list will go in the TOC.
This works by exploiting the fact that the last commands executed when \listofdirfigures
is called are (in a group)
\newfloat@listofdirfigure@hook\listoffigures
but the newfloat
package takes care to redefine things so that \listoffigures
will do the right thing. The hook is usually empty, but it's irrelevant. I redefine \listofdirfigures
(or better, the alternative version which is called \listofdirfigure
) to look for a following *
; in this case I append \append@star
to the hook, so TeX will eventually see
\append@star\listoffigures
in case \listofdirfigures*
is called; this will become \listoffigures*
as wanted. In case no *
appears, nothing is changed.
I provided an \AdjustForMemoir
macro so that every new float list making command can be modified in that way.
For reference, the memoir
only way:
\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}