\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}
答案1
对于使用该包的我来说,此代码有效subfig
。
\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}
答案2
为了subcaption
你需要不同的语法
\documentclass[11pt,a4paper,twoside]{book}
%\usepackage{caption}
\usepackage{subcaption}
\usepackage[demo]{graphicx} % [demo] is just for the example
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{0.3\textwidth}\Huge A\caption{A bounded feasible region}\label{fig:subfig5}\end{subfigure}
\begin{subfigure}{0.3\textwidth}\Huge B\caption{A bounded feasible region}\label{fig:subfig6}\end{subfigure}
\begin{subfigure}{0.3\textwidth}\Huge C\caption{A bounded feasible region}\label{fig:subfig7}\end{subfigure}
\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}
答案3
除了加载subfig
包而不是subcaption
包之外,您还应该提供一些代码来在图中三项之间提供空白。我建议您删除指令\centering
并\hspace{\fill}
在两个地方插入。
\documentclass[11pt,a4paper,twoside]{book}
%\usepackage{caption} %% not needed for this MWE
\usepackage{subfig}
\usepackage[demo]{graphicx} % [demo] is just for the example
\begin{document}
\begin{figure}[ht]
\subfloat[A bounded feasible region]{\includegraphics[width=0.3\textwidth, keepaspectratio]{2s3a.jpg}\label{fig:subfig5}}
\hspace{\fill}
\subfloat[Unbounded feasible region]{\includegraphics[width=0.3\textwidth, keepaspectratio]{2s3b.jpg}\label{fig:subfig6}}
\hspace{\fill}
\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}