我想放置 5 个子图片,第一行 3 个,第二行 2 个。后两个子图片的尺寸必须与前三个子图片相同,但要居中(我的意思是它们都靠近页面的中心,而不是在两端)。
\begin{figure}[H]
\begin{subfigmatrix}{3}
\subfigure[$\mathbb{P}^2$]{\includegraphics{Chapter3/Immagini/RSB/p2.png}}
\subfigure[$\mathbb{P}^4$]{\includegraphics{Chapter3/Immagini/RSB/p4.png}}
\subfigure[$\mathbb{P}^6$]{\includegraphics{Chapter3/Immagini/RSB/p6.png}}
\subfigure[$\mathbb{P}^8$]{\includegraphics{Chapter3/Immagini/RSB/p8.png}}
\subfigure[$\mathbb{P}^{10}$]{\includegraphics{Chapter3/Immagini/RSB/p10.png}}
\end{subfigmatrix}
\caption{RSB -- $\theta'$ contours , $\mathbb{P}^{2,4,6,8,10}$ solutions on a mesh of $2\,400$ elements using the Godunov flux.}
\label{fig:rsb}
\end{figure}
答案1
我的想法来自这里。似乎subfigmatrix
用来\hfill
设置子图之间的间距。在这里我们局部更改\hfill
为\hspace{0.1cm}
,因此子图之间始终有 0.1cm 的间距。
\documentclass{article}
\usepackage{graphicx,subfigmat,etoolbox,amssymb,float}
\begin{document}
\begin{figure}[H]
\patchcmd{\subfigmatrix}{\hfill}{\hspace{0.2cm}}{}{}
\begin{subfigmatrix}{3}
\subfigure[$\mathbb{P}^2$]{\includegraphics{example-image}}
\subfigure[$\mathbb{P}^4$]{\includegraphics{example-image}}
\subfigure[$\mathbb{P}^6$]{\includegraphics{example-image}}
\subfigure[$\mathbb{P}^8$]{\includegraphics{example-image}}
\subfigure[$\mathbb{P}^{10}$]{\includegraphics{example-image}}
\end{subfigmatrix}
\caption{RSB -- $\theta'$ contours , $\mathbb{P}^{2,4,6,8,10}$ solutions on a mesh of $2\,400$ elements using the Godunov flux.}
\label{fig:rsb}
\end{figure}
\end{document}
另一个想法
只是给你提供另一个想法:你可以subcaption
尝试\subcaptionbox
:
\documentclass{article}
\usepackage{graphicx,subcaption,amssymb}
\begin{document}
\begin{figure}
\centering
\subcaptionbox{$\mathbb{P}^2$}[0.3\linewidth]{\includegraphics[width=\linewidth]{example-image}}
\subcaptionbox{$\mathbb{P}^4$}[0.3\linewidth]{\includegraphics[width=\linewidth]{example-image}}
\subcaptionbox{$\mathbb{P}^6$}[0.3\linewidth]{\includegraphics[width=\linewidth]{example-image}}
\subcaptionbox{$\mathbb{P}^8$}[0.3\linewidth]{\includegraphics[width=\linewidth]{example-image}}
\subcaptionbox{$\mathbb{P}^{10}$}[0.3\linewidth]{\includegraphics[width=\linewidth]{example-image}}
\caption{RSB -- $\theta'$ contours , $\mathbb{P}^{2,4,6,8,10}$ solutions on a mesh of $2\,400$ elements using the Godunov flux.}
\label{fig:rsb}
\end{figure}
\end{document}
答案2
该subfigmat
软件包使用subfigure
已过时约 20 年的版本。
这是一个类似的方法,使用subfig
。需要一些技巧,因为\subfloat
会忽略其后的空格。
\documentclass{article}
\usepackage{graphicx,amssymb,subfig}
\usepackage{showframe}
\NewCommandCopy\ORIsubfloat\subfloat
\NewDocumentCommand{\NEWsubfloat}{om}{%
\begingroup\setlength{\spaceskip}{0pt}%
\IfValueTF{#1}{\ORIsubfloat[#1]{#2}}{\ORIsubfloat{#2}}%
\endgroup\space\ignorespaces
}
\newlength{\subfloatmatrixwidth}
\newenvironment{subfloatmatrix}[2][0.2cm]{%
\centering
\setlength{\subfloatmatrixwidth}{%
\dimexpr(\columnwidth-(#1)*\numexpr(#2-1)\relax)/(#2)\relax
}%
\setlength{\spaceskip}{#1 minus 1pt}%
\setkeys{Gin}{width=\subfloatmatrixwidth}%
\setlength{\lineskip}{\medskipamount}%
\RenewCommandCopy\subfloat\NEWsubfloat
}{\par}
\begin{document}
\begin{figure}[htp]
\begin{subfloatmatrix}{3}
\subfloat[$\mathbb{P}^2$]{\includegraphics{example-image}}
\subfloat[$\mathbb{P}^4$]{\includegraphics{example-image}}
\subfloat[$\mathbb{P}^6$]{\includegraphics{example-image}}
\subfloat[$\mathbb{P}^8$]{\includegraphics{example-image}}
\subfloat[$\mathbb{P}^{10}$]{\includegraphics{example-image}}
\end{subfloatmatrix}
\caption{RSB -- $\theta'$ contours , $\mathbb{P}^{2,4,6,8,10}$ solutions on
a mesh of $2\,400$ elements using the Godunov flux.}
\label{fig:rsb}
\end{figure}
\end{document}
环境还具有一个用于子浮点数之间分离的可选参数,默认为 0.2cm。
相同,但
\begin{subfloatmatrix}[0.5cm]{3}