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
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
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?
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis