[Tex/LaTex] Package caption Error: No float type ‘noticebox’ defined

captionssubcaption

I took the NIPS 2018 paper template from here, which I can compile (via pdflatex).

However, when I add this package (before \title):

\usepackage{caption}

I get the error:

! Package caption Error: No float type 'noticebox' defined.

Why? How can I fix this?
I'm using MacOSX with Texlive 2011.

A reduced example (still using the NIPS style file):

\documentclass{article}
\usepackage{nips_2018}
\usepackage[utf8]{inputenc} % allow utf-8 input
\usepackage[T1]{fontenc}    % use 8-bit T1 fonts
\usepackage{hyperref}       % hyperlinks
\usepackage{url}            % simple URL typesetting
\usepackage{booktabs}       % professional-quality tables
\usepackage{amsfonts}       % blackboard math symbols
\usepackage{nicefrac}       % compact symbols for 1/2, etc.
\usepackage{microtype}      % microtypography
\usepackage{caption}

\title{Foo}
\author{foo}

\begin{document}
\maketitle
\end{document}

(Maybe this is related. Or this.)

Adding this additional command (inspired via this) solves it, but not sure if that is a good solution, or what it does:

\DeclareCaptionType{noticebox}

Best Answer

You should upgrade your TeX Live distribution.

There is a way to solve the issue, anyhow.

\documentclass{article}
\usepackage{nips_2018}
\usepackage[utf8]{inputenc} % allow utf-8 input
\usepackage[T1]{fontenc}    % use 8-bit T1 fonts
\usepackage{caption}
\usepackage{booktabs}       % professional-quality tables
\usepackage{amsfonts}       % blackboard math symbols
\usepackage{nicefrac}       % compact symbols for 1/2, etc.
\usepackage{microtype}      % microtypography
\usepackage{hyperref}       % hyperlinks

\makeatletter
\@ifpackagelater{caption}{2011/01/01}
  {}
  {\usepackage{float}\newfloat{noticebox}{htbp}{.nb}}
\makeatother

\title{Foo}
\author{foo}

\begin{document}
\maketitle
\end{document}

I also loaded hyperref last, which is its proper position, notwithstanding what the authors of nips2018 think.

With the \@ifpackagelater instruction we only do the patch if caption is pre-2011.

Related Question