5

I'm using the package newfloat and I've added a new figure:

\DeclareFloatingEnvironment{dirfigure}

Now when I use \listofdirfigures - the list is added to the Table of Contents.

With normal figures, I can use \listoffigures* (with *) to not list it in TOC, however \listofdirfigures* doesn't work.

How to not list List of Dirfigures in TOC?

Minimal example:

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

Thanks

  • 2
    That * feature comes from memoir and iI don't know if newfloat supports it. If you created the new float using purely memoir macros (memoir has interface for it) I would guess the * feature would work – daleif May 10 '14 at 13:35
  • Didn't know that. Creating the float environment as described in memoir manual 10.1 comes with the * feature. Could you make your comment an answer, so I can approve it? Thanks a lot for your input. – hroncok May 10 '14 at 13:51
4

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

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.

  • Please report such issues/code to me in the future so I have a chance of integrating it into the newfloat package. Thanks. – Axel Sommerfeldt Apr 3 at 20:14
0

Fixed with commit https://gitlab.com/axelsommerfeldt/caption/commit/5584091f13a4d63c5245b4d8b0e9ac0171c85436

I will push a new version of the "caption package bundle" to CTAN today; in the meantime please use https://gitlab.com/axelsommerfeldt/caption/raw/master/tex/newfloat.sty as replacement of the old newfloat.sty.

BTW: Please report such issues/code to me so I will get a chance of fixing it in time. (It took me 5 years to find this issue by accident.)

  • Thanks. I wasn't aware this is a bug, I was thought I am doing it wrong. – hroncok Aug 28 at 17:48
  • 1
    @hroncok That's ok, very often users couldn't know, like in this case. The hint of mine was adressed to egreg and others who actually can. TeX SX is full of bugfixes in form of patches which uses internal macros and tend to not-working anymore in the future. This is a loose-loose situation: The bug is still there (because the author is unaware of it) and the TeX SX solution does not work anymore. And generally users get the impression that it's totally normal to patch internal stuff to get things done, which is bad for the reputation of LaTeX and could scare people off. – Axel Sommerfeldt Aug 29 at 5:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.