减少图形前后的填充(带有子图形)

减少图形前后的填充(带有子图形)

我有以下代码来在我的文档中包含两个图像:

\begin{figure}[!ht]
    \centering
    \begin{subfigure}[b]{1.0\textwidth}
        \centering
        \includegraphics[height=6.31cm]{fig1_xxx.eps}
        \caption{}
        \label{fig1}
    \end{subfigure}
    \centering
    \begin{subfigure}[b]{1.0\textwidth}
        \centering
        \includegraphics[height=6.31cm]{fig2_xxx.eps}
        \caption{}
        \label{fig2}
    \end{subfigure}
    \caption{ABC capion: (a) XYZ and (b) PQR}
\end{figure}

上述代码将两个图像垂直放置在文档的中心。但是,我发现它在插入图像之前和之后产生了很多不必要的填充。有人能建议如何解决这个问题吗?

答案1

添加到MWE的代码都会减少填充,您可以根据需要定义值

在此处输入图片描述

\documentclass{article}
\usepackage[a4paper]{geometry} % set suitable page parameters
\usepackage[T1]{fontenc}
\usepackage{caption} % optional 
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage[export]{adjustbox}

\raggedbottom
\begin{document}
\setlength{\belowcaptionskip}{-10pt}
\captionsetup{belowskip=0pt}
\renewcommand\floatpagefraction{.7}
\renewcommand\dblfloatpagefraction{.9} % for two column documents
\renewcommand\topfraction{.7}
\renewcommand\dbltopfraction{.9} % for two column documents
\renewcommand\bottomfraction{.7}
\renewcommand\textfraction{.1}   
\setcounter{totalnumber}{50}
\setcounter{topnumber}{50}
\setcounter{bottomnumber}{50}
\vspace{-7pt}
\begin{figure}[!ht]
    \centering\offinterlineskip
  \fbox{\begin{subfigure}[b]{.6\textwidth}
        \centering
        \includegraphics[vspace=0pt, height=10\baselineskip]{example-image-a}
        \caption{}
        \label{fig1}
    \end{subfigure}}

    \centering
    \fbox{\begin{subfigure}[b]{.6\textwidth}
        \centering
        \includegraphics[height=10\baselineskip]{example-image-b}

        \caption{}
        \label{fig2}
    \end{subfigure}}
    \caption{ABC capion: (a) XYZ and (b) PQR}
\end{figure}

\end{document}

如果符合要求请接受答案

相关内容