2

If I try to define a new float with:

\documentclass{mwart}
\usepackage{newfloat}
\DeclareFloatingEnvironment{plate}

It works.

But if I just change the class to

\documentclass{mwrep}
\usepackage{newfloat}
\DeclareFloatingEnvironment{plate}

I get this error message:

I get is error message:

line 6: Undefined control sequence. ...vironment[listname={List of plates}]{plate}
line 6: Missing \begin{document}. ...vironment[listname={List of plates}]{plate}
: Unsupported document class (or package) detected,(caption) usage of the caption package is not recommended.
: \caption will not be redefined since it's already(caption) redefined by a document class or package which is(caption) unknown to the caption package.

The same error happens if I use:

\usepackage{caption}

\DeclareCaptionType{plates}[Quadro][List of Plates]
\newenvironment{plate}{\captionsetup{type=plates}}{}

The book and report classes don't suffer from this problem at all. I tried to change the definition of caption to that of the default classes, but to no avail.

I know how to create a new float without a package with the mwcls classes, but the caption and newfloat packages are much more practical for that. Still, I have no idea what is causing this issue.

\documentclass{mwrep}
\usepackage{newfloat}
\usepackage[demo]{graphicx}
\usepackage{kantlipsum}
\DeclareFloatingEnvironment[listname={List of plates}]{plate}

\usepackage{caption}

\captionsetup{labelsep=endash}


\let\oldlistofplates\listofplates
\renewcommand{\listofplates}{
\begingroup%
    \let\oldnumberline\numberline%
    \renewcommand{\numberline}{Plate\ \oldnumberline}%
    \oldlistofplates%
\endgroup   

}

\begin{document}


\listoffigures
\listofplates


\section{A section}
\kant[1]
\begin{figure}[bp]
  \centering
  \includegraphics[width=2in]{fig}
  \caption{A figure}
\end{figure}
\kant[2]

\begin{plate}
  \centering
  \includegraphics[width=3in]{plate}
  \caption{A plate}
\end{plate}
\kant[3]
\end{document}
  • You say you get 'the same error' - the same as what? Which error do you get the same one of in the two cases? Please provide the exact text of the error message. – cfr Aug 16 '17 at 3:41
  • I guess mwrep and the other mw classes are not compatible with newfloat. – egreg Aug 16 '17 at 10:22
  • @egreg, I see they're not compatible -- but mwart is compatible. I just wanted to know why. I've fumbled with the caption definitions, looked thoroughly at the .cls files, but still haven't found what causes this. – BlackBird Aug 16 '17 at 10:42
  • @cfr, the same error occurs when I use the caption package and when I use the newfloat package. I guess newfloat loads caption. – BlackBird Aug 16 '17 at 10:44
2

newfloat tests whether the class has chapters by looking at \@chapter; however the mwrep class doesn't define \@chapter like the standard classes do.

\documentclass{mwrep}

% mwrep has chapters, but does not define \@chapter
\makeatletter
\providecommand{\@chapter}{}
\makeatother

\usepackage{newfloat}
\usepackage[demo]{graphicx}
\usepackage{kantlipsum}
\DeclareFloatingEnvironment[listname={List of Plates}]{plate}

\let\oldlistofplates\listofplates
\renewcommand{\listofplates}{
\begingroup%
    \let\oldnumberline\numberline%
    \renewcommand{\numberline}{Plate\ \oldnumberline}%
    \oldlistofplates%
\endgroup   

}

\begin{document}


\listoffigures
\listofplates


\section{A section}
\kant[1]
\begin{figure}[bp]
  \centering
  \includegraphics[width=2in]{fig}
  \caption{A figure}
\end{figure}
\kant[2]

\begin{plate}
  \centering
  \includegraphics[width=3in]{plate}
  \caption{A plate}
\end{plate}
\kant[3]
\end{document}

Note that caption is not compatible with mwrep, so I removed it.

| improve this answer | |

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.