[Tex/LaTex] Why latex doesn’t recognize the subfigures

floatssubfloats

\documentclass[11pt,a4paper,twoside]{book}    
\usepackage{caption}    
\usepackage{subcaption}    
\usepackage{graphicx} % [demo] is just for the example

\begin{document}    

\begin{figure}[ht]   
\centering    
\subfloat[A bounded feasible region]{\includegraphics[width=0.3\textwidth, keepaspectratio]{2s3a.jpg}\label{fig:subfig5}}    
\subfloat[Unbounded feasible region]{\includegraphics[width=0.3\textwidth, keepaspectratio]{2s3b.jpg}\label{fig:subfig6}}    
\subfloat[Unbounded feasible region]{\includegraphics[width=0.3\textwidth, keepaspectratio]{2s3c.jpg}\label{fig:subfig7}}    
\caption[Optional caption for list of figures 5-8]{Feasible region}    
\label{fig:subfigureExample2}
\end{figure}

Reference to figure \ref{fig:subfigureExample2} and \ref{fig:subfig6}.

\end{document}

The pdf which forms is shown below

Best Answer

This code works for me using the subfig package.

\documentclass[11pt,a4paper,twoside]{book}    
\usepackage{caption}    
\usepackage{subfig}    
\usepackage[demo]{graphicx} % [demo] is just for the example    

\begin{document}    

\begin{figure}[ht]   
\centering
\subfloat[A bounded feasible region]{\includegraphics[width=0.3\textwidth, keepaspectratio]{2s3a.jpg}\label{fig:subfig5}}
\subfloat[Unbounded feasible region]{\includegraphics[width=0.3\textwidth, keepaspectratio]{2s3b.jpg}\label{fig:subfig6}}
\subfloat[Unbounded feasible region]{\includegraphics[width=0.3\textwidth, keepaspectratio]{2s3c.jpg}\label{fig:subfig7}}
\caption[Optional caption for list of figures 5-8]{Feasible region}
\label{fig:subfigureExample2}
\end{figure}

Reference to figure \ref{fig:subfigureExample2} and \ref{fig:subfig6}.

\end{document}

enter image description here