![如何使用乳胶中的多列修复子标题并添加像面板一样的边框?](https://linux22.com/image/350764/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%E4%B9%B3%E8%83%B6%E4%B8%AD%E7%9A%84%E5%A4%9A%E5%88%97%E4%BF%AE%E5%A4%8D%E5%AD%90%E6%A0%87%E9%A2%98%E5%B9%B6%E6%B7%BB%E5%8A%A0%E5%83%8F%E9%9D%A2%E6%9D%BF%E4%B8%80%E6%A0%B7%E7%9A%84%E8%BE%B9%E6%A1%86%EF%BC%9F.png)
在代码中,我希望每张图片的标题以 (a)、(b) 等开头,并添加边框。但它以单独的图号形式出现。我尝试使用子图,但所有图片都位于一列中。
首先我尝试
\documentclass{article}
\usepackage{multicol}
\usepackage{graphicx}
\usepackage{float}
\begin{document}
\begin{figure}[H]
\begin{multicols}{2}
\includegraphics[width=\linewidth]{countyeffect}
\caption{Random effect due to counties obtained from spline coefficients}
\label{fig7:a} \par
\includegraphics[width=\linewidth]{statemean}\caption{Mean value of states}
\label{fig7:b} \par
\end{multicols}
\begin{multicols}{2}
\includegraphics[width=\linewidth]{stateslope} \caption{Effect due to slopes}
\label{fig7:c} \par
\includegraphics[width=\linewidth]{overalllocation}\caption{Overall location effect due to variation in states and counties}
\label{fig7:d} \par
\end{multicols}
\caption{Illustration of different kind of location effects}
\end{figure}
\end{document}
来源:两列乳胶文件中的多个图形
我得到了以下图像-
但当我尝试
\begin{figure}[H]
\begin{multicols}{2}
\begin{subfigure}{.5\textwidth}
\includegraphics[width=\linewidth]{countyeffect}
\caption{Random effect due to counties obtained from spline coefficients}
\label{fig7:a}
\includegraphics[width=\linewidth]{statemean}\caption{Mean value of states}
\label{fig7:b}
\end{subfigure}%
\end{multicols}
\begin{multicols}{2}
\begin{subfigure}{.5\textwidth}
\includegraphics[width=\linewidth]{stateslope} \caption{Effect due to slopes}
\label{fig7:c}
\includegraphics[width=\linewidth]{overalllocation}\caption{Overall location effect due to variation in states and counties}
\label{fig7:d}
\end{subfigure}%
\end{multicols}
\caption{Illustration of different kind of location effects}
\end{figure}
然后子图以 (a)、(b) 等开头。但我得到的是所有图像的单列。但我想要类似以下内容的东西-
谢谢。
答案1
使用subfig
或subcaption
包,而不是(不再维护)。对于 2x2 布局,subfigure
您不需要该 包:multicol
\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}
\begin{document}
\begin{figure}
\subfloat[\label{fig7:a}][Random effect due to counties
obtained from spline coefficients]
{\includegraphics[width=.45\linewidth]{example-image}}\hfill
\subfloat[\label{fig7:b}][Mean value of states]
{\includegraphics[width=.45\linewidth]{example-image-a}}\par
\subfloat[\label{fig7:c}][Effect due to slopes]
{\includegraphics[width=.45\linewidth]{example-image-b}}\hfill
\subfloat[\label{fig7:d}][Overall location effect due to variation
in states and counties]
{\includegraphics[width=.45\linewidth]{example-image-c}}
\caption{Illustration of different kind of location effects}
\end{figure}
\end{document}
如果您想要边框,最简单的可能是基本的 2x2 表格:
subfig
版本:
\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}
\begin{document}
\begin{figure}
\centering
\begin{tabular}{|c|c|}
\hline
\subfloat[\label{fig7:a}][Random effect due to counties obtained
from spline coefficients]
{\includegraphics[width=.45\linewidth]{example-image}} &
\subfloat[\label{fig7:b}][Mean value of states]
{\includegraphics[width=.45\linewidth]{example-image-a}}\\\hline
\subfloat[\label{fig7:c}][Effect due to slopes]
{\includegraphics[width=.45\linewidth]{example-image-b}} &
\subfloat[\label{fig7:d}][Overall location effect due to variation
in states and counties]
{\includegraphics[width=.45\linewidth]{example-image-c}}\\\hline
\end{tabular}
\caption{Illustration of different kind of location effects}
\end{figure}
\end{document}
subcaption
版本:
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
adasd
\begin{figure}
\centering
\begin{tabular}{|c|c|}\hline
\begin{subfigure}[c][5.5cm][c]{.45\linewidth}
\smallskip\includegraphics[width=\linewidth]{example-image}
\caption{Random effect due to counties obtained from
spline coefficients}
\vfill\label{fig7:a}\end{subfigure} &
\begin{subfigure}[c][5.5cm][c]{.45\linewidth}
\smallskip\includegraphics[width=\linewidth]{example-image-a}
\caption{Mean value of states}
\vfill \label{fig7:b}\end{subfigure}\\\hline
\begin{subfigure}[c][5.5cm][c]{.45\linewidth}
\smallskip\includegraphics[width=\linewidth]{example-image-b}
\caption{Effect due to slopes}
\vfill \label{fig7:c} \end{subfigure} &
\begin{subfigure}[c][5.5cm][c]{.45\linewidth}
\smallskip\includegraphics[width=\linewidth]{example-image-c}
\caption{Overall location effect due to variation in
states and counties}
\vfill\label{fig7:d}\end{subfigure} \\\hline
\end{tabular}
\caption{Illustration of different kind of location effects}
\end{figure}
\end{document}