如何将图像定位为网格

如何将图像定位为网格

我正在使用下面的代码来定位图像

\documentclass[demo]{article} % remove 'demo' option in real doc.
\usepackage{graphicx,array,booktabs}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\begin{document}

\begin{figure}[p!]
% Global parameters for \includegraphics instructions:
\setkeys{Gin}{height=0.1\textheight,width=0.1\textheight} 

\caption{[Something Descriptive for Method 1]} % provide a suitable caption
\bigskip
\centering
\begin{tabular}{@{} r @{} *{2}{M{0.1\textheight}} @{}}
& Method 1 & Residual \\
\llap{Image 1\quad} & \includegraphics{fig1a} & \includegraphics{fig1b} \\ \addlinespace
\llap{Image 2\quad} & \includegraphics{fig2a} & \includegraphics{fig2b} \\ \addlinespace
\llap{Image 3\quad} & \includegraphics{fig3a} & \includegraphics{fig3b} \\ \addlinespace
\llap{Image 4\quad} & \includegraphics{fig4a} & \includegraphics{fig4b} \\ \addlinespace
\llap{Image 5\quad} & \includegraphics{fig5a} & \includegraphics{fig5b} \\ \addlinespace
\llap{Image 6\quad} & \includegraphics{fig6a} & \includegraphics{fig6b} \\ \addlinespace
\llap{Image 7\quad} & \includegraphics{fig7a} & \includegraphics{fig7b} \\ \addlinespace
\llap{Image 8\quad} & \includegraphics{fig8a} & \includegraphics{fig8b} 
\end{tabular}
\end{figure}

\end{document}

在此处输入图片描述

但是我有 16 张图片,因为 16 张图片无法放在一页中,这使得它们太小了。所以我想将其余 8 张图片定位为侧栏。需要帮助才能做到这一点

需要做类似这样的事: 在此处输入图片描述

答案1

像这样?

在此处输入图片描述

(红线显示页面布局)

使用tabularrayadjustbox包很简单:只需声明白色表格线,将图像基线推到其垂直中心并向表格中添加两列:

\documentclass{article} 

\usepackage[demo,               % remove 'demo' option in real doc.
            export]{adjustbox}
\usepackage[table]{xcolor}
\usepackage{tabularray}
\usepackage[skip=1ex]{caption}

%---------------- Show page layout. Don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
    \begin{figure}[p]
% Global parameters for \includegraphics instructions:
\adjustboxset{height=0.1\textheight,width=0.1\textheight,valign=c}

\caption{Something Descriptive for Method 1 and Method 2} % provide a suitable caption
    \centering
\begin{tblr}{colspec={r cc cc}, colsep=3pt, rowsep=3pt,
             vline{4}={1em,white},
              }
        & Method 1                & Residual   
        & Method 2                & Residual            \\
Image 1 & \adjustimage{}{fig1a} & \adjustimage{}{fig1b}
        & \adjustimage{}{fig1c} & \adjustimage{}{fig1d} \\
Image 2 & \adjustimage{}{fig2a} & \adjustimage{}{fig2b}
        & \adjustimage{}{fig2c} & \adjustimage{}{fig2d} \\
Image 3 & \adjustimage{}{fig3a} & \adjustimage{}{fig3b}
        & \adjustimage{}{fig3c} & \adjustimage{}{fig3d} \\
Image 4 & \adjustimage{}{fig4a} & \adjustimage{}{fig4b}
        & \adjustimage{}{fig4c} & \adjustimage{}{fig4d} \\
Image 5 & \adjustimage{}{fig5a} & \adjustimage{}{fig5b}
        & \adjustimage{}{fig5c} & \adjustimage{}{fig5d} \\
Image 6 & \adjustimage{}{fig6a} & \adjustimage{}{fig6b}
        & \adjustimage{}{fig6c} & \adjustimage{}{fig6d} \\
Image 7 & \adjustimage{}{fig7a} & \adjustimage{}{fig7b}
        & \adjustimage{}{fig7c} & \adjustimage{}{fig7d} \\
Image 8 & \adjustimage{}{fig8a} & \adjustimage{}{fig8b}
        & \adjustimage{}{fig8c} & \adjustimage{}{fig8d} \\
\end{tblr}
    \end{figure}
\end{document}

答案2

另一种可能性是使用简单tabular包并添加margin选项\adjustboxset

\documentclass{article}

\usepackage[demo,               % remove 'demo' option in real doc.
            export]{adjustbox}
\usepackage{tabularx}
\usepackage[skip=1ex]{caption}

%---------------- Show page layout. Don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
    \begin{figure}[p]
% Global parameters for \includegraphics instructions:
\adjustboxset{height=0.1\textheight,width=0.1\textheight,
              margin=0pt 6pt 0pt 6pt, valign=c}

\caption{Something Descriptive for Method 1 and Method 2} % provide a suitable caption
    \centering
\begin{tabular}{r cc @{\qquad}cc}
        & Method 1                & Residual
        & Method 2                & Residual            \\
Image 1 & \adjustimage{}{fig1a} & \adjustimage{}{fig1b}
        & \adjustimage{}{fig1c} & \adjustimage{}{fig1d} \\
Image 2 & \adjustimage{}{fig2a} & \adjustimage{}{fig2b}
        & \adjustimage{}{fig2c} & \adjustimage{}{fig2d} \\
Image 3 & \adjustimage{}{fig3a} & \adjustimage{}{fig3b}
        & \adjustimage{}{fig3c} & \adjustimage{}{fig3d} \\
Image 4 & \adjustimage{}{fig4a} & \adjustimage{}{fig4b}
        & \adjustimage{}{fig4c} & \adjustimage{}{fig4d} \\
Image 5 & \adjustimage{}{fig5a} & \adjustimage{}{fig5b}
        & \adjustimage{}{fig5c} & \adjustimage{}{fig5d} \\
Image 6 & \adjustimage{}{fig6a} & \adjustimage{}{fig6b}
        & \adjustimage{}{fig6c} & \adjustimage{}{fig6d} \\
Image 7 & \adjustimage{}{fig7a} & \adjustimage{}{fig7b}
        & \adjustimage{}{fig7c} & \adjustimage{}{fig7d} \\
Image 8 & \adjustimage{}{fig8a} & \adjustimage{}{fig8b}
        & \adjustimage{}{fig8c} & \adjustimage{}{fig8d} \\
\end{tabular}
    \end{figure}
\end{document}

结果与您在第一个答案中获得的解决方案类似。

相关内容