如果我尝试使用以下命令定义一个新的浮点数:
\documentclass{mwart}
\usepackage{newfloat}
\DeclareFloatingEnvironment{plate}
有用。
但如果我只是把课程改成
\documentclass{mwrep}
\usepackage{newfloat}
\DeclareFloatingEnvironment{plate}
我收到此错误信息:
我收到的是错误信息:
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.
如果我使用,也会发生同样的错误:
\usepackage{caption}
\DeclareCaptionType{plates}[Quadro][List of Plates]
\newenvironment{plate}{\captionsetup{type=plates}}{}
book
和类report
完全不存在这个问题。我尝试将 caption 的定义更改为默认类的定义,但无济于事。
我知道如何创建一个新的浮点数,而无需使用类的包mwcls
,但caption
和newfloat
包对此更为实用。不过,我不知道是什么导致了这个问题。
\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}
答案1
newfloat
通过查看来测试该类是否有章节\@chapter
;但是该类mwrep
并没有\@chapter
像标准类那样定义。
\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}
请注意caption
与 不兼容mwrep
,因此我将其删除了。