I'm trying to redefine an existing environment subfigure
defined by the subcaption
package. To do this, I'm using xparse
's DeclareDocumentEnvironment
since that's suppose to declare a new environment no matter if it already exists or not. But for some reason I still get a compilation warning that the \subfigure
command already exists.
Here's a MWE:
\documentclass{article}
\usepackage{subcaption}
\usepackage{xparse}
\DeclareDocumentEnvironment{subfigure}{m}{%
% Do nothing
}{%
\subcaption{#1}%
}
\begin{document}
\begin{figure}
\begin{subfigure}{The caption}
The figure
\end{subfigure}
\end{figure}
\end{document}
Why doesn't this work as intended?
A workaround is of course to simply use another name for my custom environment, but I'm curious why this doesn't work as I want it to.
subcaption
that wants to definesubfigure
when\AtBeginDocument
.