如何调整图像组之间的拉伸?

How do I adjust stretching between groups of images?

我正在尝试动态生成包含大量条目的大型 PDF(1000 多页)——每个条目都包含一个标题和一个或多个图像。我希望对同一标题的图像进行分组,即如果有一个标题和两个图像,我希望它们都留在同一页上(如果它们适合的话),我已经实现了(没有测试大图像会发生什么) .

但是,我的问题是行间胶在这里很奇怪。我希望分组图像之间的 space 小于图像组之间的 space ,我尝试通过控制它们之间的 \vspace 和操纵拉伸因子来做到这一点(以便 inter-entry spaces 拉伸超过 inter-image spaces),并对 \vbox 布局进行了不同的修改,但结果很差。我可以将它们分组,或者正确对齐它们。注意:此代码是动态生成的,所以我无法手动调整。

这是一个好的页面示例:

以下是存在布局问题的页面示例: :

这就是我试图避免使用 \vboxnobreak=true 的情况:

这是一段代码:

\documentclass[12pt, a4paper, twoside]{article}

\usepackage[margin=2.5cm, bindingoffset=1cm, headheight=15pt]{geometry}

\usepackage{fontspec}
\newfontfamily{\normaltitle}{Exo 2}
\newfontfamily{\boldtitle}[UprightFont={* Bold}]{Exo 2}
\newfontfamily{\footerheaderfont}{Exo 2}

\usepackage[dvipsnames]{xcolor}
\definecolor{CustomGray}{HTML}{909090}

\usepackage{mdframed}

\usepackage{graphicx}
\graphicspath{ {D:/imgdir} }

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\footerheaderfont\small{Author}}
\fancyhead[LO,RE]{\footerheaderfont\small{Title}}


\fancyfoot[C]{}
\fancyfoot[LE]{\footerheaderfont\small\thepage}
\fancyfoot[RO]{\footerheaderfont\small\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}


\usepackage{titlesec}
\titlelabel{\thetitle.\quad}
\titleformat*{\section}{\fontsize{24}{36}\boldtitle}
\titlespacing*{\section}{0pt}{0pt}{12pt}

\setlength{\parindent}{0pt}
\setmainfont[Ligatures=TeX]{Times New Roman}

\newcommand\textbox[1]{%
    \parbox[t][][t]{\textwidth}{#1}%
}

\newcommand\dictentry[3]{
    \large
    \hangindent=0cm
    \noindent
    \textcolor{CustomGray}{#1}\textbf{#2} \hfill \small{#3}
}

\tolerance=8000



\begin{document}
    \begin{titlepage}
        \begin{center}
            \vspace*{3cm}
            
            \fontsize{36}{40}\selectfont
            
            \boldtitle{Aneks F:}
            
            \vspace{0.5cm}
            
            \normaltitle{Fotokorpus haseł \emph{SW}}
            
            \vfill
        \end{center}
    \end{titlepage}

    \setcounter{page}{202}



    \vbox{%
        \parbox{15cm}{
            \dictentry{†}
            {Fałbuła}
            {t. I (A-G), lit. F, str. 715, kol. R, ak. 32}
        }
        \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
            \includegraphics[width=\linewidth]{"page-0715, col-2, par-32 fin.png"}
        \end{mdframed}
    }

        
    \vspace{2em}%


    \vbox{%
        \parbox{15cm}{
            \dictentry{}
            {Fałd}
            {t. I (A-G), lit. F, str. 715, kol. R, ak. 33 – str. 716, kol. L, ak. 01}
        }
        \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
            \includegraphics[width=\linewidth]{"page-0715, col-2, par-33 fin.png"}
        \end{mdframed}
    }

    \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
        \includegraphics[width=\linewidth]{"page-0716, col-1, par-01 fin.png"}
        \unskip
    \end{mdframed}
            
            
    \vspace{2em}%


    \vbox{%
        \parbox{15cm}{
            \dictentry{}
            {Fałszywy}
            {t. I (A-G), lit. F, str. 717, kol. L, ak. 18 – str. 717, kol. R, ak. 01}
        }
        \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
            \includegraphics[width=\linewidth]{"page-0717, col-1, par-18 fin.png"}
        \end{mdframed}
    }
            
    \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
        \includegraphics[width=\linewidth]{"page-0717, col-2, par-01 fin.png"}
        \unskip
    \end{mdframed}
                
                    
    \vspace{2em}%


    \vbox{%
        \parbox{15cm}{
            \dictentry{}
            {Fama}
            {t. I (A-G), lit. F, str. 717, kol. R, ak. 02}
        }
        \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
            \includegraphics[width=\linewidth]{"page-0717, col-2, par-02 fin.png"}
        \end{mdframed}
    }
        
    
    \vspace{2em}%


    \vbox{%
    \parbox{15cm}{
            \dictentry{}
            {Fenacetyna}
            {t. I (A-G), lit. F, str. 731, kol. L, ak. 24}
        }
        \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
            \includegraphics[width=\linewidth]{"page-0731, col-1, par-24 fin.png"}
        \end{mdframed}
    }

        
    \vspace{2em}%


    \vbox{%
        \parbox{15cm}{
            \dictentry{}
            {Fenakistoskop}
            {t. I (A-G), lit. F, str. 731, kol. L, ak. 25}
        }
        \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
            \includegraphics[width=\linewidth]{"page-0731, col-1, par-25 fin.png"}
        \end{mdframed}
    }

        
    \vspace{2em}%
    

    \vbox{%
        \parbox{15cm}{
            \dictentry{}
            {Fenantren}
            {t. I (A-G), lit. F, str. 731, kol. L, ak. 26}
        }
        \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
            \includegraphics[width=\linewidth]{"page-0731, col-1, par-26 fin.png"}
        \end{mdframed}
        }

        
        \vspace{2em}%


        \vbox{%
            \parbox{15cm}{
                \dictentry{†}
                {Fendel}
                {t. I (A-G), lit. F, str. 731, kol. L, ak. 27 – str. 731, kol. R, ak. 01}
            }
            \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
                \includegraphics[width=\linewidth]{"page-0731, col-1, par-27 fin.png"}
            \end{mdframed}
        }
        \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
            \includegraphics[width=\linewidth]{"page-0731, col-2, par-01 fin.png"}
            \unskip
        \end{mdframed}
                    

\end{document}

编辑: `\raggebottom' 没有产生预期的效果——它似乎比 inter-group 垂直 space 更能拉伸 in-group 垂直 space,加上第 285 页的问题仍然坚持:

您可以使用\raggedbottom来避免页面内容被拉伸填满整个高度:

\documentclass[12pt, a4paper, twoside]{article}

\usepackage[margin=2.5cm, bindingoffset=1cm, headheight=15pt]{geometry}

%\usepackage{fontspec}
%\newfontfamily{\normaltitle}{Exo 2}
%\newfontfamily{\boldtitle}[UprightFont={* Bold}]{Exo 2}
%\newfontfamily{\footerheaderfont}{Exo 2}

\newcommand{\boldtitle}{}
\newcommand{\normaltitle}{}
\newcommand{\footerheaderfont}{}

\usepackage[dvipsnames]{xcolor}
\definecolor{CustomGray}{HTML}{909090}

\usepackage{mdframed}

\usepackage{graphicx}
\graphicspath{ {D:/imgdir} }

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\footerheaderfont\small{Author}}
\fancyhead[LO,RE]{\footerheaderfont\small{Title}}


\fancyfoot[C]{}
\fancyfoot[LE]{\footerheaderfont\small\thepage}
\fancyfoot[RO]{\footerheaderfont\small\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}


\usepackage{titlesec}
\titlelabel{\thetitle.\quad}
\titleformat*{\section}{\fontsize{24}{36}\boldtitle}
\titlespacing*{\section}{0pt}{0pt}{12pt}

\setlength{\parindent}{0pt}
%\setmainfont[Ligatures=TeX]{Times New Roman}

\newcommand\textbox[1]{%
    \parbox[t][][t]{\textwidth}{#1}%
}

\newcommand\dictentry[3]{
    \large
    \hangindent=0cm
    \noindent
    \textcolor{CustomGray}{#1}\textbf{#2} \hfill \small{#3}
}

\tolerance=8000



\begin{document}

\raggedbottom

    \begin{titlepage}
        \begin{center}
            \vspace*{3cm}
            
            \fontsize{36}{40}\selectfont
            
            \boldtitle{Aneks F:}
            
            \vspace{0.5cm}
            
            \normaltitle{Fotokorpus haseł \emph{SW}}
            
            \vfill
        \end{center}
    \end{titlepage}

    \setcounter{page}{202}



    \vbox{%
        \parbox{15cm}{
            \dictentry{†}
            {Fałbuła}
            {t. I (A-G), lit. F, str. 715, kol. R, ak. 32}
        }
        \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
            \includegraphics[width=\linewidth]{example-image-duck}
        \end{mdframed}
    }

        
    \vspace{2em}%


    \vbox{%
        \parbox{15cm}{
            \dictentry{}
            {Fałd}
            {t. I (A-G), lit. F, str. 715, kol. R, ak. 33 – str. 716, kol. L, ak. 01}
        }
        \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
            \includegraphics[width=\linewidth]{example-image-duck}
        \end{mdframed}
    }

    \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
        \includegraphics[width=\linewidth]{example-image-duck}
        \unskip
    \end{mdframed}
            
            
    \vspace{2em}%


    \vbox{%
        \parbox{15cm}{
            \dictentry{}
            {Fałszywy}
            {t. I (A-G), lit. F, str. 717, kol. L, ak. 18 – str. 717, kol. R, ak. 01}
        }
        \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
            \includegraphics[width=\linewidth]{example-image-duck}
        \end{mdframed}
    }
            
    \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
        \includegraphics[width=\linewidth]{example-image-duck}
        \unskip
    \end{mdframed}
                
                    
    \vspace{2em}%


    \vbox{%
        \parbox{15cm}{
            \dictentry{}
            {Fama}
            {t. I (A-G), lit. F, str. 717, kol. R, ak. 02}
        }
        \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
            \includegraphics[width=\linewidth]{example-image-duck}
        \end{mdframed}
    }
        
    
    \vspace{2em}%


    \vbox{%
    \parbox{15cm}{
            \dictentry{}
            {Fenacetyna}
            {t. I (A-G), lit. F, str. 731, kol. L, ak. 24}
        }
        \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
            \includegraphics[width=\linewidth]{example-image-duck}
        \end{mdframed}
    }

        
    \vspace{2em}%


    \vbox{%
        \parbox{15cm}{
            \dictentry{}
            {Fenakistoskop}
            {t. I (A-G), lit. F, str. 731, kol. L, ak. 25}
        }
        \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
            \includegraphics[width=\linewidth]{example-image-duck}
        \end{mdframed}
    }

        
    \vspace{2em}%
    

    \vbox{%
        \parbox{15cm}{
            \dictentry{}
            {Fenantren}
            {t. I (A-G), lit. F, str. 731, kol. L, ak. 26}
        }
        \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
            \includegraphics[width=\linewidth]{example-image-duck}
        \end{mdframed}
        }

        
        \vspace{2em}%


        \vbox{%
            \parbox{15cm}{
                \dictentry{†}
                {Fendel}
                {t. I (A-G), lit. F, str. 731, kol. L, ak. 27 – str. 731, kol. R, ak. 01}
            }
            \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
                \includegraphics[width=\linewidth]{example-image-duck}
            \end{mdframed}
        }
        \begin{mdframed}[linewidth=2pt, linecolor=CustomGray, nobreak=true]
            \includegraphics[width=\linewidth]{example-image-duck}
            \unskip
        \end{mdframed}
                    

\end{document}