Graphics, Figures & TablesNo counter 'subfigure@save' defined (subfigure not installed

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
fboehlandt
Posts: 12
Joined: Mon Apr 15, 2013 6:28 pm

No counter 'subfigure@save' defined (subfigure not installed

Post by fboehlandt »

Hi everyone,

I'm trying to use the subfig package. However, I get the known error:

Code: Select all

No counter 'subfigure@save' defined
I don't have the subfigure package installed however. Does it create conflicts with other packages (subcaption for instance)?

I am preparing a minimum working example to post
Last edited by cgnieder on Fri Jul 19, 2013 1:34 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

fboehlandt
Posts: 12
Joined: Mon Apr 15, 2013 6:28 pm

No counter 'subfigure@save' defined (subfigure not installed

Post by fboehlandt »

And here the minimum 'non'-working example. I have included all packages that I use

Code: Select all

\documentclass[preprint,authoryear,12pt]{elsarticle}

\showboxdepth=5
\showboxbreadth=5

%% usepackage
\usepackage{graphicx}
\usepackage[graphicx]{realboxes}
\usepackage{float}
\usepackage{booktabs, multicol, multirow}
\usepackage{enumerate}
\usepackage{tabularx}
\usepackage{rotating}
\usepackage{lscape}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{siunitx}
\usepackage{nameref}
\usepackage[hyphens]{url}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[retainorgcmds]{IEEEtrantools}
\usepackage[miktex]{gnuplottex}
\usepackage{pgfplots}
\usepackage{filecontents,pgfplots}
\usepackage{tkz-fct}

%% new packages
\usepackage[T1]{fontenc}
\usepackage{mwe}    % loads »blindtext« and »graphicx«
\usepackage{subfig}
%% new packages

\usetkzobj{all}
\pgfplotsset{compat=1.7}

\begin{document}

  \begin{figure}[!ht]
    \subfloat[First sub-figure\label{subfig-1:dummy}]{%
      \includegraphics[width=0.45\textwidth]{example-image-a}
    }
    \hfill
    \subfloat[First sub-figure\label{subfig-2:dummy}]{%
      \includegraphics[width=0.45\textwidth]{example-image-b}
    }
    \caption{Dummy figure}
    \label{fig:dummy}
  \end{figure}

\end{document}
fboehlandt
Posts: 12
Joined: Mon Apr 15, 2013 6:28 pm

Re: No counter 'subfigure@save' defined (subfigure not insta

Post by fboehlandt »

I found the culprit: as suspected, subcaption and subfig do not go together. Does anybody know why?
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

No counter 'subfigure@save' defined (subfigure not installed

Post by cgnieder »

This may be a stupid question but why do you want subcaption and subfig?
subcaption.png
subcaption.png (10.72 KiB) Viewed 40554 times

Code: Select all

\documentclass[preprint,authoryear,12pt]{elsarticle}
\usepackage[T1]{fontenc}

\usepackage{graphicx}
% \usepackage{float}% not needed with `caption'
\usepackage{caption}
\usepackage{subcaption}

\usepackage{mwe}    % loads »blindtext« and »graphicx«
% \usepackage{subfig}% not needed with `subcaption'

\begin{document}

\begin{figure}
  \begin{minipage}[b]{.5\linewidth}
    \centering
    \includegraphics[width=0.45\textwidth]{example-image-a}
    \subcaption{First sub-figure}\label{subfig-1:dummy}
  \end{minipage}
  \hfill
  \begin{minipage}[b]{.5\linewidth}
    \centering
    \includegraphics[width=0.45\textwidth]{example-image-b}
    \subcaption{Second sub-figure}\label{subfig-2:dummy}
  \end{minipage}
  \caption{Dummy figure}
  \label{fig:dummy}
\end{figure}

\end{document}
Regards
site moderator & package author
fboehlandt
Posts: 12
Joined: Mon Apr 15, 2013 6:28 pm

Re: No counter 'subfigure@save' defined (subfigure not insta

Post by fboehlandt »

not stupid at all. And I don't. It is probably a good idea to keep an eye on the packages installed/called and remove the ones you don't use.
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

No counter 'subfigure@save' defined (subfigure not installed

Post by sommerfee »

fboehlandt wrote:I found the culprit: as suspected, subcaption and subfig do not go together. Does anybody know why?
They use the same counters and interfaces to both the LaTeX kernel and the caption package, but in a slightly different way.
(Same goes for the subfigure package, but this one does not have an dependency on the caption package.)
Post Reply