无法在子图下获得 (a) 和 (b)

无法在子图下获得 (a) 和 (b)

我正在尝试将两个图形绘制为子图并将它们对齐。当我对齐普通图形时,图形下方会出现自动子标题,如 (a) 和 (b) 等。但是,当我将它们绘制为子图时,它不会出现在图形下方。我的代码如下。任何帮助都值得感激。

\documentclass[11pt, a4paper]{book}
\usepackage[utf8]{inputenc} 
\usepackage{float}
\usepackage[comma]{natbib}
\usepackage{pgfplots}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{tikz}
\begin{document}
\begin{figure}[H]
\centering
\subfigure{
\begin{tikzpicture}
\begin{axis}[
xlabel={Fly ash replacement ratio},
ylabel={Compressive strength ratio},
xmin=0.0, xmax=0.7,
ymin=0.2, ymax=1.2, ytick={0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.22},
legend pos=south west,
legend style={font=\fontsize{8}{20}\selectfont},
]

\addplot[smooth, color=purple, mark=o, very thick, samples=200]
coordinates {
(0, 1.0) (0.1, 0.95) (0.2, 0.86) (0.3, 0.75) (0.4, 0.61) (0.5, 0.45) (0.6, 0.28)
};
\addlegendentry{7 days}

\addplot[smooth, color=black, mark=square, very thick, samples=200]
coordinates {
(0.0, 1.0) (0.1, 0.99)(0.2, 0.94)(0.3, 0.85) (0.4, 0.75) (0.5, 0.63) (0.6, 0.5)
};
\addlegendentry{28 days}

\addplot[smooth, color=red, very thick, mark=*, samples=200]
coordinates {
(0.0, 1.0) (0.1, 1.02) (0.2, 0.99) (0.3, 0.93) (0.4, 0.85) (0.5, 0.75) (0.6, 0.63)
};
\addlegendentry{90 days}  
 \addplot[smooth, color=blue, very thick, mark=triangle,  samples=200]
coordinates {   
(0.0, 1.0) (0.1, 1.04) (0.2, 1.02) (0.3, 0.97) (0.4, 0.9) (0.5, 0.82) (0.6, 0.71)
 };
 \addlegendentry{180 days} 
\end{axis}
\end{tikzpicture}}%
\subfigure{
\begin{tikzpicture}
\begin{axis}[
xlabel={Fly ash replacement ratio},
ylabel={Compressive strength ratio},
xmin=0.0, xmax=0.7,
ymin=0.2, ymax=1.2, ytick={0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.22},
legend pos=south west,
legend style={font=\fontsize{8}{20}\selectfont},
]

\addplot[smooth, color=purple, mark=o, very thick, samples=200]
coordinates { 
(0, 1.0) (0.1, 0.97) (0.2, 0.90) (0.3, 0.80) (0.4, 0.69) (0.5, 0.56) (0.6, 0.42)
};
\addlegendentry{7 days}

\addplot[smooth, color=black, mark=square, very thick, samples=200]
coordinates {
(0.0, 1.0) (0.1, 1.01)(0.2, 0.97)(0.3, 0.91) (0.4, 0.83) (0.5, 0.73) (0.6, 0.62)
};
\addlegendentry{28 days}

\addplot[smooth, color=red, very thick, mark=*, samples=200]
    coordinates {
(0.0, 1.0) (0.1, 1.05) (0.2, 1.04) (0.3, 1.0) (0.4, 0.94) (0.5, 0.85) (0.6, 0.75)
};
\addlegendentry{90 days}  
\addplot[smooth, color=blue, very thick, mark=triangle,  samples=200]
coordinates {   
(0.0, 1.0) (0.1, 1.07) (0.2, 1.08) (0.3, 1.05) (0.4, 1.0) (0.5, 0.92) (0.6, 0.82)
 };
 \addlegendentry{180 days} 
\end{axis}
\end{tikzpicture}}%
\label{wc1}
\caption{Compressive strength evolution of concrete with different cement replacement levels. Graphs reproduced from \cite{Ge}.}
\end{figure}
\end{document}

答案1

改用subcaption

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\usepackage{caption}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{minipage}{0.3\textwidth}
\centering
\includegraphics[width=0.2\textwidth]{a}
\subcaption[first caption.]{First}\label{fig:1a}
\end{minipage}%
\begin{minipage}{0.3\textwidth}
\centering
\includegraphics[width=0.2\textwidth]{b}
\subcaption[second caption.]{Second}\label{fig:1b}
\end{minipage}%
\begin{minipage}{0.3\textwidth}
\centering
\includegraphics[width=0.2\textwidth]{c}
\subcaption[third caption.]{Third}\label{fig:1c}
\end{minipage}
\caption{Main caption\label{fig:1}}
\end{figure}
\end{document}

在此处输入图片描述

相关内容