46

I have a LaTeX file with packages

\usepackage{amsmath,amssymb}
\usepackage{graphicx}
\usepackage[colorlinks=true,citecolor=black,linkcolor=black,urlcolor=blue]{hyperref}
\usepackage{tikz,graphics,color,fullpage,float,epsf,caption,subcaption}

and I use the subfigure environment:

\begin{figure}
\begin{subfigure}{1\textwidth}
...
\end{subfigure}

\vspace{5mm}

\begin{subfigure}{1\textwidth}
...
\end{subfigure}

\end{figure}

This compiles perfectly fine on my machine. However, when I submit the LaTeX file to a journal and looks at the PDF output, it shows an error

! LaTeX Error: Environment subfigure undefined.

I'm really lost on how to fix this, since as I said, it works fine on my machine. What should I do?

EDIT: I'm using the document class

\documentclass[smallextended]{svjour3}

This site seems to have some information on the document class if necessary: http://www.e-publications.org/springer/support/spr-chicago.html

4
  • 4
    What document class are you using? Note also that hyperref should be loaded later than all those packages and that epsf should not be loaded.
    – egreg
    Commented Sep 13, 2014 at 17:42
  • 1
    to add to egreg's comment, since graphicx loads graphics, the latter is also unnecessary. Commented Sep 13, 2014 at 21:02
  • tikz loads an enhanced version of color so color is not needed either.
    – cfr
    Commented Sep 13, 2014 at 23:08
  • Your link points to bibstyle doc and not to class doc.
    – Jhor
    Commented Aug 3, 2022 at 7:44

5 Answers 5

14
+50

I would suggest a work-around, if all else fails, as it is difficult to test this without going through the submission process yourself. In that regard, avoid using the subfigure environment altogether, and default to using a tabular structure for arranging your subfigures. While this comes with manual numbering of subfigures, it's not that difficult to maintain references manually.

Here's a minimal example that should show you the implementation:

enter image description here

\documentclass[smallextended]{svjour3}
\usepackage{lipsum}% Just for this example
\usepackage{graphicx}
\begin{document}

See Figure~\ref{fig:myfig}(a) or~(b). \lipsum[1]

\begin{figure}
  \centering
  \begin{tabular}{@{}c@{}}
    \includegraphics[width=.7\linewidth,height=75pt]{example-image-a} \\[\abovecaptionskip]
    \small (a) An image
  \end{tabular}

  \vspace{\floatsep}

  \begin{tabular}{@{}c@{}}
    \includegraphics[width=.6\linewidth,height=100pt]{example-image-b} \\[\abovecaptionskip]
    \small (b) Another image
  \end{tabular}

  \caption{This is a figure caption}\label{fig:myfig}
\end{figure}

\lipsum[2]

\end{document}
0
44

or you can try:

\usepackage{subcaption}
\captionsetup{compatibility=false}
1
  • So weird that this works, but \usepackage{subfig} doesn't. Oh well.
    – axolotl
    Commented Oct 7, 2020 at 2:49
2

As you have mentioned that you add the package subcaption:

\usepackage{tikz,graphics,color,fullpage,float,epsf,caption,subcaption}

You can then do the following ways to work around this (which in my case is working):

Using the subcaptiongroup environment

\begin{figure}
  \centering
  \begin{subcaptiongroup}
    \centering
    \parbox[b]{.4\textwidth}{%
    \centering
    \includegraphics{cat}
    \caption{A cat}\label{cat}}%
    \parbox[b]{.4\textwidth}{%
    \centering
    \includegraphics{elephant}
    \caption{An elephant}\label{elephant}}%
  \end{subcaptiongroup}
  \caption{Two animals}\label{animals}
\end{figure}

Sample 1

Your output will be still the same and the conflict of the error with the subfigure should now have disappeared.

For the subfigure, you can also use \phantomcaption:

\begin{figure}
  \centering
  \begin{subcaptiongroup}
    \includegraphics{cat_with_a}
    \phantomcaption\label{cat}
    \includegraphics{elephant_with_b}
    \phantomcaption\label{elephant}
  \end{subcaptionblock}
  \captionsetup{subrefformat=parens}
  \caption{Two animals: \subref{cat} a cat, and \subref{elephant} an 
  elephant}
\label{animals}
\end{figure}

Also, by working around with the subcaption package:

\usepackage{subcaption}
\captionsetup[sub]{⟨options⟩}

The default settings for sub-captions are:

margin=0pt,font+=smaller,labelformat=parens,labelsep=space,
skip=6pt,list=false,hypcap=false
0

Look at this link: https://dev.to/latexteada/latex-more-in-figures-side-by-side-figures-44i3 Ultimately all you have to do is:

\begin{figure}
\centering
\includegraphics[width=.3\linewidth]{//path} % Just stack two includegraphics!
\includegraphics[width=.3\linewidth]{\\path}
\caption{A subfigure}
\label{fig:sub1}
\end{figure}
2
  • Ths doesn't answer to OP which asks for \includegraphics on top of each other. And doesn't in anyway fixes the subcaption issue.
    – Jhor
    Commented Aug 3, 2022 at 7:42
  • I do not know why this answer got thumbs down, actually in some contexts, it also works. To further modify you even can add \hfill or \vfill in between two \includegraphics
    – bim
    Commented Mar 8, 2023 at 15:27
-1

The captionsetup did not work for me but i could keep the same structure by simply exchanging the subfigure parts with minipage like this:

\begin{figure}[H]
    \centering
    \begin{minipage}{0.49\textwidth}
        \includegraphics[width=\linewidth, height=4.5cm]{images/test1.JPG} 
        \caption{Test 1}
    \end{minipage}
    \hfill
    \begin{minipage}{0.49\textwidth}
        \includegraphics[width=\linewidth, height=4.5cm]{images/test2.JPG}
        \caption{Test 2}
    \end{minipage}
\caption{Test figures for minipage \cite{testReference}}
\label{fig:test}
\end{figure}
1
  • 1
    Welcome on tex.sx. Your solution as presented won't compile. To enable the use of \caption in a minipage, you w'd need some \captionsetup in preamble or in the minipage.
    – Jhor
    Commented Aug 3, 2022 at 7:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .