如何用不同大小的子图填充页面

如何用不同大小的子图填充页面

我有一个 5x2 子图数组。我的文档具有 IEEEtran 样式,我正在使用以下测试代码:

\documentclass[journal,twocolumn,10pt]{IEEEtran}   
\usepackage{graphicx}
\usepackage{mwe}% just for the example content

\begin{document}

\blindtext

\begin{figure*}

\includegraphics[width=.2\textwidth]{_kkk/javier-sesion-14-SEC-6-FRAMES.pdf}\hfill
\includegraphics[width=.25\textwidth]{_kkk/javier-sesion-14-SEC-6-ALL.pdf}
\\[\smallskipamount]
\includegraphics[width=.55\textwidth]{_kkk/javier-sesion-14-SEC-3-FRAMES.pdf}\hfill
\includegraphics[width=.25\textwidth]{_kkk/javier-sesion-14-SEC-3-ALL.pdf}
\\[\smallskipamount]
\includegraphics[width=.4\textwidth]{_kkk/javier-sesion-14-SEC-26-FRAMES.pdf}\hfill
\includegraphics[width=.25\textwidth]{_kkk/javier-sesion-14-SEC-26-ALL.pdf}
\\[\smallskipamount]
\includegraphics[width=.6\textwidth]{_kkk/javier-sesion-14-SEC-16-FRAMES.pdf}\hfill
\includegraphics[width=.25\textwidth]{_kkk/javier-sesion-14-SEC-16-ALL.pdf}
\\[\smallskipamount]
\includegraphics[width=.6\textwidth]{_kkk/javier-sesion-14-SEC-7-FRAMES.pdf}\hfill
\includegraphics[width=.25\textwidth]{_kkk/javier-sesion-14-SEC-7-ALL.pdf}

\caption{Combinations examples from session S4}
\label{SESION4}
\end{figure*}

\blindtext

\end{document}

PDF 图在此关联

在此处输入图片描述

我希望看起来像这样

在此处输入图片描述

如果可能的话,留下很少的空间来填充,填充文本的宽度长度。

其中一个问题可能是*-FRAMES.pdf图形周围的白色边缘。

答案1

周围的空白*-FRAMES.pdf并不统一,每个图形都不同。可以使用trimclip在 内进行修剪\includegraphics,但这确实需要测量(或猜测)每个左、右、上和下边距。如果有很多图形,则需要大量手动操作。

因此我选择了一个两步的工作流程:

(1)使用pdfcrop删除目录cropFig.tex中的所有空格,运行_kkk

您将得到六个新的人物,现在它们被整齐地裁剪并命名*FRAMES-crop.pdf

需要 pdflatex 并 \write18启用。对于大多数 TeX 发行版,--shell-escape在运行 latex/pdflatex 时设置标志。

例如,使用 TeXstudio,设置

pdflatex.exe -synctex=1 -interaction=nonstopmode -shell-escape %.tex

查看示例https://tex.stackexchange.com/a/151669/161015

(2) 要设计图形,使用表格环境更容易。我之所以选择它,nicematrix是因为它提供了一个 \Block命令,可以将内容垂直居中在单元格中,而无需任何额外的包。

的长度\FrameHeight用于控制框架的高度和宽度,从而控制整个图形的高度和宽度。

根据您的评论,我将高度设置* ALL.pdf1.4\FrameHeight

d

这是主要代码:

\documentclass[journal,twocolumn,10pt]{IEEEtran}   
\usepackage{graphicx}
%\usepackage{mwe}% just for the example content

\usepackage{showframe} % show the margin

\usepackage{nicematrix} % added <<<<
\usepackage[center]{caption} % centering the caption


\begin{document}    

\newlength{\FrameHeight}
\setlength{\FrameHeight}{0.16\textwidth} % to control the figure Frame width and height

\begin{figure*}

\begin{NiceTabular}{rl}[cell-space-limits=6pt] % add space between rows 
        
\Block{}{\includegraphics[keepaspectratio,height=\FrameHeight]{_kkk/javier-sesion-14-SEC-6-FRAMES-crop.pdf}}&
\Block{}{\includegraphics[keepaspectratio,height=1.4\FrameHeight]{_kkk/javier-sesion-14-SEC-6-ALL.pdf}}
    \\ 
\Block{}{\includegraphics[keepaspectratio,height=\FrameHeight]{_kkk/javier-sesion-14-SEC-3-FRAMES-crop.pdf}}&
\Block{}{\includegraphics[keepaspectratio,height=1.4\FrameHeight]{_kkk/javier-sesion-14-SEC-3-ALL.pdf}}
    \\
\Block{}{\includegraphics[keepaspectratio,height=\FrameHeight]{_kkk/javier-sesion-14-SEC-26-FRAMES-crop.pdf}}&
\Block{}{\includegraphics[keepaspectratio,height=1.4\FrameHeight]{_kkk/javier-sesion-14-SEC-26-ALL.pdf}}
    \\
\Block{}{\includegraphics[keepaspectratio,height=\FrameHeight]{_kkk/javier-sesion-14-SEC-16-FRAMES-crop.pdf}}&
\Block{}{\includegraphics[keepaspectratio,height=1.4\FrameHeight]{_kkk/javier-sesion-14-SEC-16-ALL.pdf}}
    \\
\Block{}{\includegraphics[keepaspectratio,height=\FrameHeight]{_kkk/javier-sesion-14-SEC-7-FRAMES-crop.pdf}}&
\Block{}{\includegraphics[keepaspectratio,height=1.4\FrameHeight]{_kkk/javier-sesion-14-SEC-7-ALL.pdf}} \\ 
    
\end{NiceTabular}

\caption{Combinations examples from session S4}\label{SESION4}
\end{figure*}   
    
\end{document}

这是文件cropFig.tex

% !TeX TS-program = pdflatex %%<<<<<<<<<<<<<<<<<<<<<<

%% file cropFig.tex

\documentclass{article}

\usepackage{graphicx}
% From https://tex.stackexchange.com/a/151669/161015
\newcommand{\includeCroppedPdf}[2][]{%
    \immediate\write18{pdfcrop #2}%
    \includegraphics[#1]{#2-crop}}

\begin{document}
\noindent   \includeCroppedPdf[width=\textwidth]{javier-sesion-14-SEC-3-FRAMES}
            \includeCroppedPdf[width=\textwidth]{javier-sesion-14-SEC-6-FRAMES}
            \includeCroppedPdf[width=\textwidth]{javier-sesion-14-SEC-7-FRAMES}
            \includeCroppedPdf[width=\textwidth]{javier-sesion-14-SEC-16-FRAMES}
            \includeCroppedPdf[width=\textwidth]{javier-sesion-14-SEC-26-FRAMES}
\end{document}

以及其部分产出

X

更新二

使左边的数字变小,右边的数字变大:

通过更改,\AllHeight您可以修改图形的高度*ALL(和宽度,它们是正方形)。要在一页上插入五个图形,其高度应略小于文本高度的 1/5,以便留出标题的空间。

\FrameHeight可以修改所有 *ALL` 图形的高度,*FRAME' figures relative to the height of同时允许最宽的图形适合页面的左侧。

是

\documentclass[journal,twocolumn,10pt]{IEEEtran}   
\usepackage{graphicx}
%\usepackage{mwe}% just for the example content

%\usepackage{showframe} % show the margin

\usepackage{nicematrix} % added <<<<
\usepackage[center]{caption} % centering the caption
    
\begin{document}    

\newlength{\FrameHeight}
\newlength{\AllHeight}
    
\setlength{\FrameHeight}{0.13\textwidth} % to control the figure(s) *FRAMA width (and height)   
\setlength{\AllHeight}{0.19\textheight} % to control the figure(s) *ALL width and height. (It is a square)

\begin{figure*}
 \setlength{\tabcolsep}{10pt} %columns separation
 
\begin{NiceTabular}{rc}[cell-space-limits=0pt] % add space between rows          
        
\Block{}{\includegraphics[keepaspectratio,height=\FrameHeight]{_kkk/javier-sesion-14-SEC-6-FRAMES-crop.pdf}}&
\Block{}{\includegraphics[keepaspectratio,height=\AllHeight]{_kkk/javier-sesion-14-SEC-6-ALL.pdf}}
    \\ 
\Block{}{\includegraphics[keepaspectratio,height=\FrameHeight]{_kkk/javier-sesion-14-SEC-3-FRAMES-crop.pdf}}&
\Block{}{\includegraphics[keepaspectratio,height=\AllHeight]{_kkk/javier-sesion-14-SEC-3-ALL.pdf}}
    \\
\Block{}{\includegraphics[keepaspectratio,height=\FrameHeight]{_kkk/javier-sesion-14-SEC-26-FRAMES-crop.pdf}}&
\Block{}{\includegraphics[keepaspectratio,height=\AllHeight]{_kkk/javier-sesion-14-SEC-26-ALL.pdf}}
    \\
\Block{}{\includegraphics[keepaspectratio,height=\FrameHeight]{_kkk/javier-sesion-14-SEC-16-FRAMES-crop.pdf}}&
\Block{}{\includegraphics[keepaspectratio,height=\AllHeight]{_kkk/javier-sesion-14-SEC-16-ALL.pdf}}
    \\
\Block{}{\includegraphics[keepaspectratio,height=\FrameHeight]{_kkk/javier-sesion-14-SEC-7-FRAMES-crop.pdf}}&
\Block{}{\includegraphics[keepaspectratio,height=\AllHeight]{_kkk/javier-sesion-14-SEC-7-ALL.pdf}}  \\ 
    
\end{NiceTabular}

\caption{Combinations examples from session S4}\label{SESION4}
\end{figure*}   
    
\end{document

答案2

使用包\adjincludegraphics中定义的adjustbox,通过使用定义常见的图像特征\adjustboxset(例外是本地添加的)并在表格中排列图像,其中第一列的内容右对齐,第二列的内容左对齐:

\documentclass[journal]{IEEEtran}
\usepackage[export]{adjustbox}
\usepackage{array, booktabs}

\usepackage{lipsum}                             % for dummy text

\begin{document}

    \begin{figure*}
\adjustboxset{height=0.08\textheight, 
              width=\linewidth,
              % keepaspectratio, % add when are used original images
              margin=0pt 3pt 0pt 3pt
              }

\begin{tabular*}{\textwidth}{@{} 
    >{\raggedleft}m{\dimexpr0.75\textwidth-\tabcolsep}  
                  m{\dimexpr0.25\linewidth-\tabcolsep} 
                             @{}}
\adjincludegraphics[height=0.16\textheight, % at original image
                    width=.2\textwidth]{example-image-duck}
    &   \adjincludegraphics{example-image}\par
        \adjincludegraphics{example-image}   \\
    \addlinespace
\adjincludegraphics[height=0.16\textheight,
                    width=.55\textwidth]{example-image-duck}
    &   \adjincludegraphics{example-image}\par
        \adjincludegraphics{example-image}   \\
    \addlinespace
\adjincludegraphics[height=0.16\textheight,
                    width=.4\textwidth]{example-image-duck}
    &   \adjincludegraphics{example-image}\par
        \adjincludegraphics{example-image}   \\
    \addlinespace
\adjincludegraphics[height=0.16\textheight,
                    width=.6\textwidth]{example-image-duck}
    &   \adjincludegraphics{example-image}\par
        \adjincludegraphics{example-image}   \\
    \addlinespace
\adjincludegraphics[height=0.16\textheight,
                    width=.6\textwidth]{example-image-duck}
    &   \adjincludegraphics{example-image}\par
        \adjincludegraphics{example-image}   \\
\caption{Combinations examples from session S4}
\end{tabular*}
    \end{figure*}
\lipsum\lipsum
\end{document}

在此处输入图片描述

笔记:通过 s 的高度example-image模拟原始图像的未知高度。

编辑:

您的评论完全不清楚您的问题到底是什么,因此几乎不可能帮助您。我只能向您展示一个想法,即如何简单地排列您的图像。由于您的图像未知,因此我留下了有关图像(其大小)的所有详细信息。在下面的 MWE 中,图像大小仅通过heightwidth选项模拟(基于 MWE 中给定的宽度) includegraphics

\documentclass[journal]{IEEEtran}
\usepackage{graphicx}
\usepackage{array, booktabs}

\usepackage{lipsum}                             % for dummy text

\begin{document}

    \begin{figure*}
\setkeys{Gin}{height=0.18\textheight,
              width=\linewidth,  % image width is defined by column width
              % keepaspectratio, % add when are used original images
              }

\begin{tabular*}{\textwidth}{@{}
    >{\raggedleft}m{\dimexpr0.75\textwidth-\tabcolsep}
                  m{\dimexpr0.25\linewidth-\tabcolsep}
                             @{}}
\includegraphics[height=0.13\textheight, % simulate height of original image
                    width=.2\textwidth]{example-image-duck}
    &   \includegraphics{example-image}   \\
    \addlinespace
\includegraphics[height=0.13\textheight,
                    width=.55\textwidth]{example-image-duck}
    &   \includegraphics{example-image}   \\
    \addlinespace
\includegraphics[height=0.13\textheight,
                    width=.4\textwidth]{example-image-duck}
    &   \includegraphics{example-image}   \\
    \addlinespace
\includegraphics[height=0.13\textheight,
                    width=.6\textwidth]{example-image-duck}
    &   \includegraphics{example-image}   \\
    \addlinespace
\includegraphics[height=0.13\textheight,
                    width=.6\textwidth]{example-image-duck}
    &   \includegraphics{example-image}   \\
\caption{Combinations examples from session S4}
\end{tabular*}
    \end{figure*}
\lipsum\lipsum
\end{document}

在此处输入图片描述

相关内容