如何获得 4x2 子图?

如何获得 4x2 子图?

我想得到一个 4 行 x 2 列的子图,但我不知道如何让 2 幅图像并排。我从帮助页面和各种帮助站点复制并粘贴了代码,但都不起作用。图像堆叠在一起,而不是获得 2 列。这是我的代码示例:

\documentclass[a4paper, 11pt, oneside]{Thesis}
\graphicspath{Figures/}  % Location of the graphics files (set up for graphics 

\usepackage{graphicx}
\usepackage{subfiles}
\usepackage{subfig}

\begin{document}

\begin{figure}[]
    \centering
    \begin{subfigure}[b]{0.4\textwidth}
    \centering
        \includegraphics[width=\linewidth]{Figures/2µm_lines_CA_graph}
        \caption{Contact angle with various pseudo dosages}
        \label{fig:2µm_lines_CA_graph}
    \end{subfigure}
    ~ %add desired spacing between images, e. g. ~, \quad, \qquad, \hfill etc. 
      %(or a blank line to force the subfigure onto a new line)

    \begin{subfigure}[]{0.4\textwidth}
    \centering
        \includegraphics[width=\linewidth]{Figures/2µm_lines_CAH_graph}
        \caption{Contact angle with various pseudo dosages}
        \label{fig:2µm_lines_CAH_graph}
    \end{subfigure}
    \caption{Contact angles on 2 $\mu$m Lines}\label{fig:2µm_lines_CA_graphs}
\end{figure}

\end{document}

答案1

  • 您的问题与这里许多类似的问题重复,例如 Bobyandbob 在其评论中指出的那样每页设置 4x2 个图形

  • 除此之外,您还存在一些(题外话)问题:

    • 对于subfigure环境,您需要加载subcaption包(我不知道是否使用文档类来thesis执行此操作)
    • 的加载subfig是多余的(它与 不兼容subcaption
    • 具有环境宽度的图像subfigure毫无意义地居中

考虑到上述情况,你的 MWE 成为

\documentclass[a4paper, 11pt, oneside]{book}% i haven't thesis document class
%\graphicspath{Figures/}  % Location of the graphics files (set up for graphics

\usepackage[demo]{graphicx}
\usepackage{subcaption}

\begin{document}

\begin{figure}[htp]
    \centering
    \begin{subfigure}[b]{0.4\textwidth}
        \includegraphics[width=\linewidth]{Figures/2µm_lines_CA_graph}
        \caption{Contact angle with various pseudo dosages}
        \label{fig:2µm_lines_CA_graph}
    \end{subfigure}
\hfil
    \begin{subfigure}[b]{0.4\textwidth}
        \includegraphics[width=\linewidth]{Figures/2µm_lines_CAH_graph}
        \caption{Contact angle with various pseudo dosages}
        \label{fig:2µm_lines_CAH_graph}
    \end{subfigure}

    \begin{subfigure}[b]{0.4\textwidth}
        \includegraphics[width=\linewidth]{Figures/2µm_lines_CA_graph}
        \caption{Contact angle with various pseudo dosages}
        \label{fig:2µm_lines_CA_graph}
    \end{subfigure}
\hfil
    \begin{subfigure}[b]{0.4\textwidth}
        \includegraphics[width=\linewidth]{Figures/2µm_lines_CAH_graph}
        \caption{Contact angle with various pseudo dosages}
        \label{fig:2µm_lines_CAH_graph}
    \end{subfigure}

    \begin{subfigure}[b]{0.4\textwidth}
        \includegraphics[width=\linewidth]{Figures/2µm_lines_CA_graph}
        \caption{Contact angle with various pseudo dosages}
        \label{fig:2µm_lines_CA_graph}
    \end{subfigure}
\hfil
    \begin{subfigure}[b]{0.4\textwidth}
        \includegraphics[width=\linewidth]{Figures/2µm_lines_CAH_graph}
        \caption{Contact angle with various pseudo dosages}
        \label{fig:2µm_lines_CAH_graph}
    \end{subfigure}

    \begin{subfigure}[b]{0.4\textwidth}
        \includegraphics[width=\linewidth]{Figures/2µm_lines_CA_graph}
        \caption{Contact angle with various pseudo dosages}
        \label{fig:2µm_lines_CA_graph}
    \end{subfigure}
\hfil
    \begin{subfigure}[b]{0.4\textwidth}
        \includegraphics[width=\linewidth]{Figures/2µm_lines_CAH_graph}
        \caption{Contact angle with various pseudo dosages}
        \label{fig:2µm_lines_CAH_graph}
    \end{subfigure}
    \caption{Contact angles on 2 $\mu$m Lines}\label{fig:2µm_lines_CA_graphs}
\end{figure}

\end{document}

相关内容