4

I am trying to format my 2x3 figure plot...

Because I wanted the figure to be smaller and fit on one page with some text I scalled every subfigure from 0.5 down to 0.35. I suspect this is already not best practise.

But now I don't manage to have the middle two sub figures to be centered. And I have tried all possible \hspace*{\fill} combinations, but cannot figure it out...

Here is my code:

\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}

This produces the following: enter image description here

How can I make sure that subfigure (c) and (d) are centered like the other subfigures?

Thank you in advance!!

1 Answers1

3

You should replace all three instances of \hspace*{\fill} with a blank line, which will force a line break. I would further suggest that unless you want the pairs of graphs to be really, really close to one another, you separate them with \quad or \qquad directives; \hspace{\fill} would absolutely maximize the horizontal separation.

enter image description here

\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}

Mico
  • 506,678
  • 2
    This is perfect, thank you so much, also for the explanations! I always just hack everything together, time to invest some time into actually understanding what's going on... – casparschwa Dec 12 '20 at 11:35