Latex's method of typesetting multiple pictures in the same figure

Latex's method of typesetting multiple pictures in the same figure

minipage(子图)Grammar is mainly used . minipageIt can be nested, and the subgraph can be decomposed into more subgraphs. The function is very interesting. If you are bored, you can try it yourself. The following describes several commonly used effects of the realization of the method.

Display two plots side by side and label them separately

\begin{figure}[thbp!]
    \centering
    \begin{minipage}[t]{0.49\linewidth}
        \centering
        \includegraphics[width=0.9\linewidth]{figure/opencv-logo.png}
        \caption{OpenCV的logo}
        \label{fig:opencv_logo}
    \end{minipage}
    \begin{minipage}[t]{0.49\linewidth}
        \centering
        \includegraphics[width=0.9\linewidth]{figure/gdalicon_big.png}
        \caption{GDAL的logo}
        \label{fig:gdal_logo}
    \end{minipage}
 \end{figure}

The result of the above code is:
insert image description here
In particular, it should be noted that the sum of the width of the first minipage and the width of the second minipage cannot exceed 1. If it exceeds one, it will automatically become a vertical arrangement, as shown in the following figure:

\begin{figure}[thbp!]
    \centering
    \begin{minipage}[t]{0.49\linewidth}% 注意!0.49
        \centering
        \includegraphics[width=0.9\linewidth]{figure/opencv-logo.png}
        \caption{OpenCV的logo}
        \label{fig:opencv_logo}
    \end{minipage}
    \begin{minipage}[t]{0.59\linewidth}% 注意!0.49+上面的0.59>1,导致自动重排版
        \centering
        \includegraphics[width=0.9\linewidth]{figure/gdalicon_big.png}
        \caption{GDAL的logo}
        \label{fig:gdal_logo}
    \end{minipage}
 \end{figure}

insert image description here

Display two graphs side by side with only one label \label

Try the following code, figure/opencv-logo, figure/gdalicon_big are the relative paths of the two pictures, indicating the two pictures opencv-logo.png and gdalicon_big.png under the figure folder. Then the code to display them side by side and mark them as a whole is as follows:

\begin{figure}[thbp!]
    \centering
    \begin{minipage}[t]{0.49\linewidth}
        \centering
        \includegraphics[width=0.9\linewidth]{figure/opencv-logo}
        %\caption{第1个子图标题}
    \end{minipage}
    \begin{minipage}[t]{0.49\linewidth}
        \centering
        \includegraphics[width=0.9\linewidth]{figure/gdalicon_big}
        %\caption{第2个子图标题}
    \end{minipage}
    \caption{并排安放两张图}
    \label{fig:image_group}
 \end{figure}

The syntax is similar to that of the previous section, except that the or minipageis not used for each , so as not to number them.\caption\label
insert image description here

Note that if the command minipageis also used in the included picture , the subfigure \captionwill also be numbered, as shown in the following figure:minipage

\begin{figure}[thbp!]
    \centering
    \begin{minipage}[t]{0.49\linewidth}
        \centering
        \includegraphics[width=0.9\linewidth]{figure/opencv-logo.png}
        \caption{OpenCV的logo}
    \end{minipage}
    \begin{minipage}[t]{0.49\linewidth}
        \centering
        \includegraphics[width=0.9\linewidth]{figure/gdalicon_big.png}
        \caption{GDAL的logo}
    \end{minipage}
    \caption{并排安放两张图}
    \label{fig:image_group}
 \end{figure}

insert image description here

So, how to mark the subgraph without numbering it?

Add explanatory text to subfigures without numbering

Achieving this effect requires the use of tabularpackages.

\begin{figure}[thbp!]
    \centering
    \begin{tabular}{@{\extracolsep{\fill}}c@{}c@{\extracolsep{\fill}}}
            \includegraphics[width=0.5\linewidth]{figure/opencv-logo.png} &
            \includegraphics[width=0.5\linewidth]{figure/gdalicon_big.png}\\
            (a)OpenCV的logo & (b)GDAL的logo\\
    \end{tabular}
    \caption{并排,但不标记子图}
    \label{fig:image_with_table}
 \end{figure}

figureNest a two-row, two-column table in , insert two pictures into the first line, insert the description text of the two pictures into the second line, and finally label the whole thing once figure. The effect is as follows:
insert image description here

Another example, typesetting 6 pictures by 321:

\begin{figure}[thbp!]
    \centering
    \begin{minipage}[t]{1.0\linewidth}
    \centering
        \begin{tabular}{@{\extracolsep{\fill}}c@{}c@{}c@{}@{\extracolsep{\fill}}}
            \includegraphics[width=0.33\linewidth]{figure/opencv-logo} &
            \includegraphics[width=0.33\linewidth]{figure/gdalicon_big}&
            \includegraphics[width=0.33\linewidth]{figure/eigen_logo}\\
            (a)OpenCV的logo & (b)GDAL的logo & (c)Eigen的logo\\
        \end{tabular}
    \end{minipage}
    \begin{minipage}[t]{1.0\linewidth}
    \centering
        \begin{tabular}{@{\extracolsep{\fill}}c@{}c@{}@{\extracolsep{\fill}}}
            \includegraphics[width=0.33\linewidth]{figure/vtk_logo} &
            \includegraphics[width=0.33\linewidth]{figure/qt}\\
            (d)vtk的logo & (e)Qt的logo\\
        \end{tabular}
    \end{minipage}
    \begin{minipage}[t]{1.0\linewidth}
    \centering
        \begin{tabular}{@{\extracolsep{\fill}}c@{}@{\extracolsep{\fill}}}
            \includegraphics[width=0.33\linewidth]{figure/vcpkg_logo}\\
            (f)vcpkg的logo\\
        \end{tabular}
    \end{minipage}
    \caption{3行,每行子图数不同,子图不编号}
    \label{fig:image_with_table_321}
 \end{figure}

The code uses 3 minipageto complete the setting of 3 rows of pictures respectively; each is minipageembedded with one tabularto realize the text description (not marked) of the current row of sub-pictures; the tabularnumber of lines for each is 2, the first row of sub-pictures, the second Behavior description text, the number of columns is the number of subgraphs in this row.
The effect is as follows:

insert image description here

Guess you like

Origin blog.csdn.net/qq_42679415/article/details/130894937