5

I want to make a figure consisting of two subfigures. Having read the Wikipedia subentry on subfloats, I tried to follow it exactly, so I did not use the subfig or subfigure package, only the caption and subcaption packages. Nevertheless, I am getting a Missing number, treated as zero error, pointing to the line with \begin{subfigure}.

What am I doing wrong?

Below is my code:

% In preamble:
\usepackage{url}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{rotating}
\usepackage[table]{xcolor}
\usepackage{multirow}
\usepackage{amsfonts}


% In document:
\begin{figure}[htpb]
\begin{subfigure}[b]{width=0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{img_a}
\end{subfigure}
\begin{subfigure}[b]{width=0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{img_b}
\end{subfigure}
\caption{A caption.}
\label{fig:my-figure}
\end{figure}
Alexis Pigeon
  • 7,423
  • 11
  • 39
  • 44
Amittai Aviram
  • 2,270
  • 3
  • 25
  • 32
  • NB: The subfig and subfigure packages are both supposed to be deprecated; hence I used subcaption instead. – Amittai Aviram Aug 29 '12 at 08:34
  • 1
    you'll get better luck at http://tex.stackexchange.com – Kuf Aug 29 '12 at 08:34
  • 1
    Duplicate posted: [Subfloat with subcaption package: Missing number, treated as zero](http://tex.stackexchange.com/questions/69336/5764) – Werner Aug 29 '12 at 17:55

0 Answers0