I am currently writing my own document class (which is very inspired by the book class) and I am facing a problem when using the caption
and subcaption
packages.
Here's a part of my classemphasized text:
\RequirePackage{caption}
\RequirePackage{subcaption}
\newcounter{figure}
\newenvironment{figure}{%
\@float{figure}%
}
{\end@float}
\renewcommand\thefigure{%
\@arabic\c@figure%
}
\renewcommand\thesubfigure{%
\arabic{subfigure}%
}
\newcommand\figurename{Fig}
\def\fps@figure{tbp}
\def\ftype@figure{1}
\def\ext@figure{lof}
\def\fnum@figure{\figurename\nobreakspace\thefigure}
\DeclareCaptionLabelFormat{format}{\textbf{\textsc{#1.~#2. -- }}}
\captionsetup[figure]{
name={Fig},
labelsep=none,
labelformat=format,
textformat=simple,
justification=justified,
singlelinecheck=true,
font=footnotesize,
textfont=it,
position=bottom,
}
\captionsetup[subfigure]{
name={Fig},
labelsep=none,
labelformat=format,
textformat=simple,
justification=justified,
singlelinecheck=true,
font=footnotesize,
textfont=it,
position=bottom,
}
For the simple figures, no problem, everything goes perfectly well. But when I try to insert subfigures I get the following error concerning the document class:
Command \thesubfigure undefined
Do you know where this mistake came from? I've read the documentation of both packages but I'm not very advanced. . .
This is the first time I write my own document class, it's quite different from a "classical" use of LaTeX, so please excuse me if my class is a makeshift job. Thanks
PS : Here is link for the document class : MyClass.cls
The figure environment is defined on lines 382 to 410 and the caption on lines 452 to 510.
And here is the link for .tex file : Test.tex
\newcounter{figure}
before\RequirePackage{subcaption}
or manually use\DeclareCaptionSubType[*]{figure}
(see doc ofsubcaption
, sec. 5). When loadingsubcaption
,\DeclareCaptionSubType
is called automatically forfigure
andtable
, if the corresponding counters are defined..cls
and.tex
files?