如何确保所有子图均位于 2x3 图形的中心?

如何确保所有子图均位于 2x3 图形的中心?

我正在尝试格式化我的 2x3 图形图......

因为我希望图形更小,并能与一些文本一起放在一页上,所以我将每个子图形的尺寸从 0.5 缩小到 0.35。我怀疑这已经不是最佳实践了。

但现在我无法让中间两个子图居中。我尝试了所有可能的\hspace*{\fill}组合,但还是无法解决...

这是我的代码:

\subsection{Hashing power distributions}
\begin{figure}[!htb]
    \centering
\begin{subfigure}{0.35\textwidth}
    \includegraphics[width=\linewidth]{/Users/css/dev/thesis/selfish_mining_abm/notebooks/figures/hash_distribution/UNIFORM_0.png}
    \caption{First subfigure} \label{fig:a}
\end{subfigure}
\begin{subfigure}{0.35\textwidth}
\includegraphics[width=\linewidth]{/Users/css/dev/thesis/selfish_mining_abm/notebooks/figures/hash_distribution/UNIFORM_15.png}
\caption{Second subfigure} \label{fig:b}
\end{subfigure}
\hspace*{\fill}
\begin{subfigure}{0.35\textwidth}
\includegraphics[width=\linewidth]{/Users/css/dev/thesis/selfish_mining_abm/notebooks/figures/hash_distribution/POWERLAW_0.png}
\caption{Third subfigure} \label{fig:c}
\end{subfigure}
\begin{subfigure}{0.35\textwidth}
\includegraphics[width=\linewidth]{/Users/css/dev/thesis/selfish_mining_abm/notebooks/figures/hash_distribution/POWERLAW_15.png}
\caption{Fourth subfigure} \label{fig:d}
\end{subfigure}
\hspace*{\fill}
\begin{subfigure}{0.35\textwidth}
\includegraphics[width=\linewidth]{/Users/css/dev/thesis/selfish_mining_abm/notebooks/figures/hash_distribution/EXPONENTIAL_0.png}
\caption{Fifth subfigure} \label{fig:e}
\end{subfigure}
\begin{subfigure}{0.35\textwidth}
\includegraphics[width=\linewidth]{/Users/css/dev/thesis/selfish_mining_abm/notebooks/figures/hash_distribution/EXPONENTIAL_15.png}
\caption{Sixth subfigure} \label{fig:f}
\end{subfigure}
\hspace*{\fill}
\caption{Relative selfish revenue as a function of selfish hashing power ($\alpha$) for different hashing power distributions and topologies} \label{fig:1}
\end{figure}

这将产生以下内容: 在此处输入图片描述

我如何确保子图 (c) 和 (d) 与其他子图一样位于中心?

先感谢您!!

答案1

您应该用空白行替换所有三个实例\hspace*{\fill},这将强制换行。我进一步建议,除非您希望图表对彼此非常非常接近,否则请使用\quad\qquad指令将它们分开;\hspace{\fill}绝对可以最大化水平分离。

在此处输入图片描述

\documentclass[demo]{article} % remove 'demo' option in real document
\usepackage{subcaption,graphicx}
\begin{document}
\subsection{Hashing power distributions}
\begin{figure}[!htb]
\centering
\begin{subfigure}{0.35\textwidth}
    \includegraphics[width=\linewidth]{/Users/css/dev/thesis/selfish_mining_abm/notebooks/figures/hash_distribution/UNIFORM_0.png}
    \caption{First subfigure} \label{fig:a}
\end{subfigure}\qquad
\begin{subfigure}{0.35\textwidth}
\includegraphics[width=\linewidth]{/Users/css/dev/thesis/selfish_mining_abm/notebooks/figures/hash_distribution/UNIFORM_15.png}
\caption{Second subfigure} \label{fig:b}
\end{subfigure}   

\medskip % for some added vertical separation
\begin{subfigure}{0.35\textwidth}
\includegraphics[width=\linewidth]{/Users/css/dev/thesis/selfish_mining_abm/notebooks/figures/hash_distribution/POWERLAW_0.png}
\caption{Third subfigure} \label{fig:c}
\end{subfigure}\qquad
\begin{subfigure}{0.35\textwidth}
\includegraphics[width=\linewidth]{/Users/css/dev/thesis/selfish_mining_abm/notebooks/figures/hash_distribution/POWERLAW_15.png}
\caption{Fourth subfigure} \label{fig:d}
\end{subfigure}  

\medskip % for some added vertical separation
\begin{subfigure}{0.35\textwidth}
\includegraphics[width=\linewidth]{/Users/css/dev/thesis/selfish_mining_abm/notebooks/figures/hash_distribution/EXPONENTIAL_0.png}
\caption{Fifth subfigure} \label{fig:e}
\end{subfigure}\qquad
\begin{subfigure}{0.35\textwidth}
\includegraphics[width=\linewidth]{/Users/css/dev/thesis/selfish_mining_abm/notebooks/figures/hash_distribution/EXPONENTIAL_15.png}
\caption{Sixth subfigure} \label{fig:f}
\end{subfigure}

\caption{Relative selfish revenue as a function of selfish hashing power ($\alpha$) for different hashing power distributions and topologies} \label{fig:1}
\end{figure}
\end{document}

相关内容