0

I'm trying to create a figure with two tikzfigures as subfigures. The problem seems to be in the subcaption style. This is the error that I'm getting:

! LaTeX Error: Command \c@subfigure already defined. Or name \end... illegal, see p.192 of the manual.

This is my MWE

\documentclass[12pt,a4paper]{extarticle} %,twoside Usado en latex-ssau-gost-style-master
%\usepackage{mutavel}   % Usado en latex-ssau-gost-style-master                    
\RequirePackage[T2A]{fontenc} 
\RequirePackage[utf8]{inputenc}
\RequirePackage[russian]{babel}

\RequirePackage{subcaption} 
\renewcommand{\thesubfigure}{\asbuk{subfigure}}
  
%%%%%%%TIKZ%%%%%%%
\usepackage{tikz}    
% FIGURES
\usepackage{subfigure}

\begin{document}

\begin{figure}[h]
    \centering
    \subfigure[Image 1]{
    \begin{tikzpicture}
    \draw[-stealth] (0,0)--(0,-5)  node[anchor= east]{x}; %X
    \draw[-stealth] (0,0)--(5,0)  node[anchor=west]{z}; %Z
    
    \coordinate[label=$A$] (a) at (1,-1);
    \coordinate[label=$B$] (b) at (5,-1);
    \coordinate[label=$C$] (c) at (1,-5.65);
    \coordinate[label=$D$] (d) at (5,-5.65);
    \coordinate[label=$\textup{к.т}$] (control) at (3,-4);
    
    \draw [line width=0.25mm](a)--(b)--(5,-5)--(1,-5)--(a);
    \draw [line width=0.25mm](3,-1)--(3,-5);    
    \draw [line width=0.25mm](1,-4)--(5,-4);
    \draw plot [mark=*, mark size=1.8] coordinates{(3,-4)}; 
    \end{tikzpicture}
    }
    \subfigure[Image 2]{
    \begin{tikzpicture}
    \draw[-stealth] (0,0)--(0,-5)  node[anchor= east]{x}; %X
    \draw[-stealth] (0,0)--(5,0)  node[anchor=west]{z}; %Z
    
    \coordinate[label=$A$] (a) at (1,-1);
    \coordinate[label=$B$] (b) at (5,-1);
    \coordinate[label=$C$] (c) at (1,-5.65);
    \coordinate[label=$D$] (d) at (5,-5.65);
    \coordinate[label=$\textup{к.т}$] (control) at (3,-4);
    
    \draw [line width=0.25mm](a)--(b)--(5,-5)--(1,-5)--(a);
    \draw [line width=0.25mm](2,-1)--(2,-5);    
    \draw [line width=0.25mm](3,-1)--(3,-5);
    \draw [line width=0.25mm](4,-1)--(4,-5);    
    \draw [line width=0.25mm](1,-2)--(5,-2);
    \draw [line width=0.25mm](1,-3)--(5,-3);
    \draw [line width=0.25mm](1,-4)--(5,-4);
    \draw plot [mark=*, mark size=1.8] coordinates{(3,-4)}; 
    \end{tikzpicture}
    }
    \caption{MWE}
    \label{fig:ejemplo}
\end{figure}    
\end{document}

Works if the style is commented, and looks like:

enter image description here

1 Answer 1

3

Packages subcaption and subfigure are not compatible. For example, they both define counter "subfigure".

To choose one from them, I recommend subcaption, which is under better maintenance. So, to make your example work,

  • Remove the line \usepacakge{subfigure}
  • Change two occurrences of \subfigure command to \subfloat.
  • [Optional but recommended] Replace \RequirePacakge by \usepackage, the former is designed for use in document classes and packages.

Full example:

\documentclass[12pt,a4paper]{extarticle} %,twoside Usado en latex-ssau-gost-style-master
%\usepackage{mutavel}   % Usado en latex-ssau-gost-style-master                    
\usepackage[T2A]{fontenc} 
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}

\usepackage{subcaption}
\renewcommand{\thesubfigure}{\asbuk{subfigure}}
  
%%%%%%%TIKZ%%%%%%%
\usepackage{tikz}    


\begin{document}

\begin{figure}[h]
    \centering
    \subfloat[Image 1]{
    \begin{tikzpicture}
    \draw[-stealth] (0,0)--(0,-5)  node[anchor= east]{x}; %X
    \draw[-stealth] (0,0)--(5,0)  node[anchor=west]{z}; %Z
    
    \coordinate[label=$A$] (a) at (1,-1);
    \coordinate[label=$B$] (b) at (5,-1);
    \coordinate[label=$C$] (c) at (1,-5.65);
    \coordinate[label=$D$] (d) at (5,-5.65);
    \coordinate[label=$\textup{к.т}$] (control) at (3,-4);
    
    \draw [line width=0.25mm](a)--(b)--(5,-5)--(1,-5)--(a);
    \draw [line width=0.25mm](3,-1)--(3,-5);    
    \draw [line width=0.25mm](1,-4)--(5,-4);
    \draw plot [mark=*, mark size=1.8] coordinates{(3,-4)}; 
    \end{tikzpicture}
    }
    \subfloat[Image 2]{
    \begin{tikzpicture}
    \draw[-stealth] (0,0)--(0,-5)  node[anchor= east]{x}; %X
    \draw[-stealth] (0,0)--(5,0)  node[anchor=west]{z}; %Z
    
    \coordinate[label=$A$] (a) at (1,-1);
    \coordinate[label=$B$] (b) at (5,-1);
    \coordinate[label=$C$] (c) at (1,-5.65);
    \coordinate[label=$D$] (d) at (5,-5.65);
    \coordinate[label=$\textup{к.т}$] (control) at (3,-4);
    
    \draw [line width=0.25mm](a)--(b)--(5,-5)--(1,-5)--(a);
    \draw [line width=0.25mm](2,-1)--(2,-5);    
    \draw [line width=0.25mm](3,-1)--(3,-5);
    \draw [line width=0.25mm](4,-1)--(4,-5);    
    \draw [line width=0.25mm](1,-2)--(5,-2);
    \draw [line width=0.25mm](1,-3)--(5,-3);
    \draw [line width=0.25mm](1,-4)--(5,-4);
    \draw plot [mark=*, mark size=1.8] coordinates{(3,-4)}; 
    \end{tikzpicture}
    }
    \caption{MWE}
    \label{fig:ejemplo}
\end{figure}    
\end{document}

enter image description here

2
  • Thank you. Those packages are includes in mutavel style. Should I replace \RequirePacakge by \usepackage there? Jun 11, 2020 at 12:37
  • 1
    @OscarEspinosa In general: in cls or sty file, use \RequirePackage. In tex file than contains \begin{document} ... \end{document}, use \usepacakge. Jun 11, 2020 at 12:39

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.