With the following minimal example, there are the nested environments code and quadro
, where both use captionsetup
. And when building the the example, I got the warning: Package caption Warning: The caption type was already set to `quadro' on input line 38.See the caption package documentation for explanation
I managed to fix it by replacing the line \captionsetup[quadro]{skip=1mm}
by \AtBeginEnvironment{quadro}{\captionsetup{skip=1mm}}
.
But I do not understand what is happening. Reading the documentation it says:
The caption type was already set to ‘htypei’. This warning informs you about mixed caption options. For example if you use a \captionsetup{type=table} or \captionof{table}{. . . } inside a figure environment, this would result in using both option sets for that specific caption, the one for figure (specified with \captionsetup[figure]{. . .}) and the one for table (specified with \captionsetup[table]{. . . }) as well. (You can suppress this warning by using the starred form \captionsetup*{type=. . .}.) (See section 3.2: Setting options)
Why replacing \captionsetup[quadro]{skip=1mm}
by \AtBeginEnvironment{quadro}{\captionsetup{skip=1mm}}
fixes the warning?
\documentclass[
brazilian,brazil,
12pt, % Padrão UFSC para versão final
a4paper, % Padrão UFSC para versão final
twoside, % Impressão nos dois lados da folha
chapter=TITLE, % Título de capítulos em caixa alta
section=TITLE, % Título de seções em caixa alta
]{abntex2}
\usepackage{caption}
\usepackage{listings}
\usepackage[newfloat,chapter]{minted}
\newenvironment{code}{
\captionsetup{type=listing}
}{}
\AtBeginEnvironment{code}{\setcounter{listing}{\value{lstlisting}}
\captionsetup{skip=0pt}
}
\def\listofquadrosname{List of Frames}
\def\quadrosname{Frame}
\DeclareFloatingEnvironment[fileext=loq,placement={!hbtp},name=\quadrosname,within=chapter,listname=\listofquadrosname]{quadro}
\captionsetup[quadro]{skip=1mm}
% \AtBeginEnvironment{quadro}{\captionsetup{skip=1mm}}
\begin{document}
\begin{quadro}[h]
\caption{Example}
\begin{code}
\caption{File}
Something.
\end{code}
\end{quadro}
\end{document}