# Error when trying to use the subcaption package

When I try to use the subcaption package (\usepackage{subcaption}), I get some errors. However, using the subfigure package (\usepackage{subfigure}), the compilation is successful with no errors. I cannot figure out what is wrong...

here is a code example:

\documentclass[12pt, a4paper, oneside]{book}
\usepackage{fullpage}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{alltt}
\usepackage{latexsym}
\usepackage{exscale}
\usepackage[numbers, sort&compress]{natbib}
\usepackage{rotating}
\usepackage{changepage}
%\usepackage{notoccite}

%a useful package if you write url addresses:
%\usepackage{url}

\usepackage[labelfont=bf]{caption}
\usepackage{subcaption}

\usepackage{epsfig}

\begin{document}

\begin{figure}[htb]
\centering
\subfigure[]
{
\label{fig: Image1}
\includegraphics[width=76mm,height=60mm]{CordicStruc.pdf}
}
\subfigure[]
{
\label{fig: Image2}
\includegraphics[width=76mm,height=60mm]{Diagram1.pdf}
}

\caption{\textbf{(a) Block diagram of floating-
point CORDIC co-processor architecture.} \textbf{(b) Pre-Process module in CORDIC co-processor.}}
\end{figure}

\end{document}

• Welcome to TeX.SX! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – jub0bs Aug 25 '13 at 0:43

## 1 Answer

The problem is that they are different packages, and that they do not work in the same way. The subfigure package defines a \subfigure command that is used to create subfigures, as in

\subfigure{\includegraphics{image}}


subcaption does not define such a command, but it does define a subfigure environment, used as

\begin{subfigure}{.5\textwidth}
\includegraphics{image}
\caption{...}
\end{subfigure}


It also defines a \subcaptionbox command, that you can use.

Here is your code adapted to the subcaption package. I added examples for both the subfigure environment and \subcaptionbox command.

Note that the demo option to graphicx replaces the images with black rectangles, remove it for your own document.

\documentclass[12pt, a4paper, oneside]{book}
\usepackage[demo]{graphicx}

\usepackage[labelfont=bf]{caption}
\usepackage{subcaption}

\begin{document}

\begin{figure}[htb]
\centering
\begin{subfigure}{\linewidth}
\centering
\includegraphics[width=76mm,height=60mm]{CordicStruc.pdf}
\caption{}
\label{fig: Image1}
\end{subfigure}
\begin{subfigure}{\linewidth}
\centering
\includegraphics[width=76mm,height=60mm]{Diagram1.pdf}
\caption{}
\label{fig: Image1}
\end{subfigure}
\caption{\textbf{(a) Block diagram of floating-
point CORDIC co-processor architecture.} \textbf{(b) Pre-Process module in CORDIC co-processor.}}
\end{figure}

\begin{figure}[htb]
\centering
\subcaptionbox{}{\includegraphics[width=76mm,height=60mm]{CordicStruc.pdf}}
\subcaptionbox{}{\includegraphics[width=76mm,height=60mm]{Diagram1.pdf}}
\caption{\textbf{(a) Block diagram of floating-
point CORDIC co-processor architecture.} \textbf{(b) Pre-Process module in CORDIC co-processor.}}
\end{figure}

\end{document}