I'm trying to use the subfig package. However, I get the known error:
Code: Select all
No counter 'subfigure@save' defined
I am preparing a minimum working example to post
Code: Select all
No counter 'subfigure@save' defined
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
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}
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}
They use the same counters and interfaces to both the LaTeX kernel and the caption package, but in a slightly different way.fboehlandt wrote:I found the culprit: as suspected, subcaption and subfig do not go together. Does anybody know why?
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