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}
Best 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 insubcaption
does not define such a command, but it does define asubfigure
environment, used asIt also defines a
\subcaptionbox
command, that you can use.Here is your code adapted to the
subcaption
package. I added examples for both thesubfigure
environment and\subcaptionbox
command.Note that the
demo
option tographicx
replaces the images with black rectangles, remove it for your own document.