如何调整图像组之间的拉伸?
我正在尝试动态生成一个包含大量条目的大型 PDF(1000 多页),每个条目都包含一个标题和一个或多个图像。我希望将相同标题的图像分组,即如果有一个标题和两个图像,我希望它们都保留在同一页面上(如果它们可以容纳),我已经实现了这一点(无需测试大图像会发生什么) 然而,
我的问题是,行间粘合在这里非常奇怪,我希望分组图像之间的空间小于图像组之间的空间,我尝试通过控制它们之间的 \vspace
来实现这一点。拉伸因子(以便条目间空间拉伸超过图像间空间),并对 \vbox 布局进行了不同的修改,但我可以将它们分组,或者正确对齐它们。 注意:此代码是动态生成的,因此我无法
这是我试图避免使用 \vbox
和 nobreak=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' 没有产生预期的效果 - 它似乎比组间垂直空间拉伸组内垂直空间更多,而且第 285 页的问题仍然存在:
I am trying to dynamically generate a large PDF (1000+ pages) with lots of entries—each consisting of a caption and one or more images. I want the images for the same caption to be grouped, i.e. if there is a caption and two images, I want both to stay on the same page (if they can fit), which I have achieved (without testing what happens with large images.
However, my problem is that interline glue is very odd here. I would expect the space between grouped images to be smaller than between groups of images, which I tried doing by controlling \vspace
between them and manipulating stretch factor (so that inter-entry spaces stretch more than inter-image spaces), and different modifications to \vbox layout, but it produced poor results. I can either make them grouped, or align them properly. Note: this code is generated dynamically, so I cannot manually adjust it.
Here is an example of good page:
Here are examples of pages with layout problems:
:
And here is what I am trying to avoid using \vbox
and nobreak=true
:
And here's the a fragment of code:
\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}
Edit:
`\raggebottom' doesn't produce the desired effect – it seems to stretch the in-group vertical spaces more than inter-group vertical spaces, plus the problem from page 285 still persists:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
\raggedbottom
来避免页面内容被拉伸以填充整个高度:You can use
\raggedbottom
to avoid the content of the page to be stretched to fill the entire height: