如果我的 tcolorbox 框几乎占据了整个页面,我该如何减少“Underfull \vbox badness”警告?

如果我的 tcolorbox 框几乎占据了整个页面,我该如何减少“Underfull \vbox badness”警告?

我想使用tcolorbox这个包几乎占据了整个页面,这是我在课堂上使用 LuaLaTeX 编译的文档的 MWE scrbook

% !TeX program = lualatex

% DOCUMENT CLASS
\documentclass[%
% draft,
twoside,
headings=openany, % parts/chapters start on any page whether it's odd or even
DIV=15, % division factor
BCOR=12.5mm, % binding correction
headsepline=1.5pt, % header line
footsepline=0.4pt, % footer line
numbers=noenddot, % no dots at the end of section numbering
]{scrbook} % 11pt, a4paper (default)
% ----------------------------------------------------
% PACKAGES
\usepackage[
automark,
% footheight=18pt
]{scrlayer-scrpage} % KOMA-script package for headers, footers, pagestyles
\usepackage{setspace}\setdisplayskipstretch{} % For spacing
\usepackage[english]{babel}
\usepackage[babel]{microtype} % Microtypography
\usepackage{lipsum, blindtext} % For lorem ipsum dummy texts
\usepackage{mathtools, amsthm, amssymb} % Math packages
\usepackage{physics} % Physics package
\usepackage[warnings-off={mathtools-colon,mathtools-overbracket}]{unicode-math} % Math fonts
\usepackage[theorems]{tcolorbox} % Colored boxes
\usepackage{empheq} % Emphasize equations
\usepackage{xcolor} % For colors
\usepackage{xparse} % For document-level commands
\usepackage{xpatch} % For patching commands
\usepackage{etoolbox} % e-TeX toolbox for classes and packages
\usepackage[
hidelinks
]{hyperref} % Hyperlinks and references
\usepackage[capitalise, nameinlink]{cleveref} % Clever cross-referencing features
\usepackage{showframe} % For page layout diagrams
% ----------------------------------------------------
% LAYOUT
  % Headers and footers
\renewcommand{\chaptermarkformat}{\chapapp~\thechapter.\enskip} % Add period after chapter number in header
\automark[section]{chapter} % LE and RO headers
\addtokomafont{pagenumber}{\normalsize\bfseries}
\ifoot*{} % inner footer
\cfoot*{\pagemark} % central footer
\ofoot*{} % outer footer
  % Part and chapter pagestyles
\renewcommand*{\partpagestyle}{empty}
\renewcommand*{\chapterpagestyle}{plain}
  % Section numbering
\setcounter{secnumdepth}{\subsectionnumdepth}
  % Section headings
% Font sizes
\setkomafont{part}{\Huge}
\setkomafont{chapter}{\huge}
\setkomafont{section}{\LARGE}
\setkomafont{subsection}{\Large}
% Replace \autodot by a fixed dot for chapter headings
\xpretocmd\chapterformat
  {\def\autodot{.}}
  {}{\cfPatchFailed}
% Spacing
\renewcommand*{\chapterheadstartvskip}{\vspace*{0cm}}
\renewcommand*{\chapterheadendvskip}{\vspace*{\baselineskip}}
\RedeclareSectionCommands[
  beforeskip=-.5\baselineskip,
  afterskip=.5\baselineskip
]{section}
\RedeclareSectionCommands[
  beforeskip=-.5\baselineskip,
  afterskip=.25\baselineskip
]{subsection}
% ----------------------------------------------------
% MACROS
  % Disable the error from using \label with amsmath nested environments
\makeatletter
\def\label@in@display{\gdef\df@label}
\makeatother
  % \ifstringsequalTF and \stringcase
\ExplSyntaxOn
\NewExpandableDocumentCommand{\ifstringsequalTF}{mmmm}
 {
  \str_if_eq:eeTF { #1 } { #2 } { #3 } { #4 }
 }
\NewExpandableDocumentCommand{\stringcase}{mO{}m}
 {
  \str_case_e:nnF { #1 } { #3 } { #2 }
 }
\ExplSyntaxOff
  % Positive space 
\newcommand{\PositiveSpace}{}
\NewDocumentCommand{\PS}{r()}
{%
\renewcommand{\PositiveSpace}{#1}
\ifstringsequalTF{\PositiveSpace}{0.5}%
  {\quad}{}%
\ifstringsequalTF{\PositiveSpace}{1}%
  {\qquad}{}%
\ifstringsequalTF{\PositiveSpace}{1.5}%
  {\qquad\quad}{}%
\ifstringsequalTF{\PositiveSpace}{2}%
  {\qquad\qquad}{}%
\ifstringsequalTF{\PositiveSpace}{2.5}%
  {\qquad\qquad\quad}{}%
\ifstringsequalTF{\PositiveSpace}{3}%
  {\qquad\qquad\qquad}{}%
\ifstringsequalTF{\PositiveSpace}{3.5}%
  {\qquad\qquad\qquad\quad}{}%
\ifstringsequalTF{\PositiveSpace}{4}%
  {\qquad\qquad\qquad\qquad}{}%
\ifstringsequalTF{\PositiveSpace}{4.5}%
  {\qquad\qquad\qquad\qquad\quad}{}%
\ifstringsequalTF{\PositiveSpace}{5}%
  {\qquad\qquad\qquad\qquad\qquad}{}%
}
  % Negative space 
\newcommand{\minusquad}{\mkern-18mu}
\newcommand{\minusqquad}{\mkern-36mu}
\newcommand{\NegativeSpace}{}
\NewDocumentCommand{\NS}{r()}
{%
\renewcommand{\NegativeSpace}{#1}
\ifstringsequalTF{\NegativeSpace}{0.5}%
  {\minusquad}{}%
\ifstringsequalTF{\NegativeSpace}{1}%
  {\minusqquad}{}%
\ifstringsequalTF{\NegativeSpace}{1.5}%
  {\minusqquad\minusquad}{}%
\ifstringsequalTF{\NegativeSpace}{2}%
  {\minusqquad\minusqquad}{}%
\ifstringsequalTF{\NegativeSpace}{2.5}%
  {\minusqquad\minusqquad\minusquad}{}%
\ifstringsequalTF{\NegativeSpace}{3}%
  {\minusqquad\minusqquad\minusqquad}{}%
\ifstringsequalTF{\NegativeSpace}{3.5}%
  {\minusqquad\minusqquad\minusqquad\minusquad}{}%
\ifstringsequalTF{\NegativeSpace}{4}%
  {\minusqquad\minusqquad\minusqquad\minusqquad}{}%
\ifstringsequalTF{\NegativeSpace}{4.5}%
  {\minusqquad\minusqquad\minusqquad\minusqquad\minusquad}{}%
\ifstringsequalTF{\NegativeSpace}{5}%
  {\minusqquad\minusqquad\minusqquad\minusqquad\minusqquad}{}%
}
  % Resizeable \bullet symbol
\newcommand{\rbullet}[1][.75]{\mathbin{\vcenter{\hbox{\scalebox{#1}{$\bullet$}}}}}
  % amsthm theorem environments
\newtheoremstyle{dotlessplain}
  {\topsep}   % ABOVESPACE
  {\topsep}   % BELOWSPACE
  {\itshape}  % BODYFONT
  {0pt}       % INDENT (empty value is the same as 0pt)
  {\(\rbullet\) \bfseries} % HEADFONT
  { }         % HEADPUNCT
  {\newline} % HEADSPACE
  {\thmname{#1}\thmnumber{ #2}\thmnote{ (#3)}}
\theoremstyle{dotlessplain} % italic
\newtheorem{theorem}{Theorem}[chapter]
    % tcolorbox environments
\newtcolorbox{summary}[2][]{colback=black!5!white,
colframe=black,boxrule=1pt,arc=2mm,toptitle=3mm,bottomtitle=3mm,center title,title=\textbf{\Large% 
Summary #2},#1}
% ----------------------------------------------------
% DOCUMENT
\begin{document}
% Page 1
\onehalfspacing
\KOMAoptions{DIV=current}
\chapter{First Chapter}
\section{First Section}
\subsection{First Subsection}
\lipsum[1-5][1-79]
\pagebreak
% Page 2
\begin{summary}[boxsep=0pt,left=10pt,right=10pt,top=10pt,bottom=10pt]{of Chapter 1}
\(\rbullet\) \textbf{Properties of Addition and Multiplication}
\begin{align*}
    &\text{(Associative law for addition)} \PS(0.5) & a + (b + c) &= (a + b) + c. \tag{P1}  \\
    &\text{(Existence of an additive identity)} \PS(0.5) & a + 0 &= 0 + a = a. \tag{P2} \\
    &\text{(Existence of additive inverses)} \PS(0.5) & a + (-a) &= (-a) + a = 0. \tag{P3} \\
    &\text{(Commutative law for addition)} \PS(0.5) & a + b &= b + a. \tag{P4} \\
    &\text{(Associative law for multiplication)} \PS(0.5) & a \cdot (b \cdot c) &= (a \cdot b) \cdot c. \tag{P5} \\
    &\text{(Existence of a multiplicative identity)} \PS(0.5) & a \cdot 1 &= 1 \cdot a = a;\quad 1 \neq 0. \tag{P6} \\
    &\text{(Existence of multplicative inverses)} \PS(0.5) & a \cdot a^{-1} &= a^{-1} \cdot a = 1, \text{ for } a \neq 0.  \tag{P7} \\
    &\text{(Commutative law for multiplication)} \PS(0.5) & a \cdot b &= b \cdot a. \tag{P8} \\
    &\text{(Distributive law)} \PS(0.5) & a \cdot (b + c) &= a \cdot b + a \cdot c. \tag{P9}
\end{align*}
\vskip 2ex
\(\rbullet\) \textbf{Properties of Inequality and Closure}
\begin{gather*}
    \begin{flalign*}
        &\text{(Trichotomy law) }  \text{For every number } a, \text{one and only one of the following holds:} & \tag{P10}
    \end{flalign*}
    \\
    \begin{align*}
        &\text{(i) } a = 0, && \\
        &\text{(ii) } a \text{ is in the collection } P, && \\
        &\text{(iii) } -a \text{ is in the collection } P. &&
    \end{align*}
    \\[7pt]
    \begin{flalign*}
        &\text{(Closure under addition) If } a \text{ and } b \text{ are in } P, \text{then } a + b \text{ is in } P. & \tag{P11} \\[5pt]
        &\text{(Closure under multiplication) If } a \text{ and } b \text{ are in } P, \text{then } a \cdot b \text{ is in } P. & \tag{P12}
    \end{flalign*}
\end{gather*}
\vskip -3ex
\begin{align*}
    &\PS(0.5) a > b \PS(0.5)\text{ if }\PS(0.5)  a - b \text{ is in } P; \\
    &\PS(0.5) a < b \PS(0.5)\text{ if }\PS(0.5) b > a; \\
    &\PS(0.5) a \geq b \PS(0.5)\text{ if }\PS(0.5) a > b \text{ or } a = b; \\
    &\PS(0.5) a \leq b \PS(0.5)\text{ if }\PS(0.5) a < b \text{ or } a = b.
\end{align*}
\vskip 2ex
\(\rbullet\) \textbf{Definition of the Absolute Value}
\begin{equation*}
\abs{a} = \sqrt{a^2} =
    \begin{cases*}
        \phantom{-}a, & if \(a\geq 0\) \\
        -a, & if \(a\leq 0\).
    \end{cases*}
\end{equation*}
\vskip 3ex
\begin{theorem}[\href{https://en.wikipedia.org/wiki/Triangle_inequality}{The Triangle Inequality}] 
        For all numbers \(a\) and \(b\), we have
        \[\abs{a + b} \leq \abs{a} + \abs{b}.\]
    \end{theorem}
\end{summary}
\vspace{\fill}
\pagebreak
% Page 3
\chapter{Second Chapter}
\section{Second Section}
\subsection{Second Subsection}
\lipsum[1-5][1-79]
\end{document}

在外行人看来,结果似乎还不错

第 1 页 第2页 第 3 页

但我不明白为什么 LaTeX 告诉我有Underfull \vbox (badness ...)警告。

警告

所以,我的问题是,我该如何减少不良程度以消除针对这种情况的警告?

我一直在到处寻找如何减少/消除Underfull \vbox (badness ...)LaTeX 给出的警告的解决方案,有些解决方案建议我可以简单地抑制警告,但我担心这可能会影响整个文档的排版,所以到目前为止我一直避免这样做。谢谢。

答案1

您可以添加\raggedbottom以避免段落之间有额外的空间来填充页面。

我将在以下示例中向您展示使用与不使用的区别。为了简化起见,我没有使用您的 MWE,而只是为了解释这个概念。

此示例不使用\raggedbottom

\documentclass{book}
\usepackage{graphicx}
\usepackage{tcolorbox}
\usepackage{lipsum}
\begin{document}
\chapter{This is what happens \emph{without} \textbackslash \texttt{raggedbottom}}
Some text before the box.
Some text before the box.
Some text before the box.
Some text before the box.
\begin{tcolorbox}[title=My first box, colframe=red]
\lipsum[1]
\end{tcolorbox}
Some text after the box.
Some text after the box.
Some text after the box.
Some text after the box.
\begin{tcolorbox}[title=My second box, colframe=green]
\lipsum[1]
\end{tcolorbox}
\end{document}

输出为:

在此处输入图片描述

这是同样的例子\raggedbottom

\documentclass{book}
\usepackage{graphicx}
\usepackage{tcolorbox}
\usepackage{lipsum}
\raggedbottom
\begin{document}
\chapter{This is what happens \emph{with} \textbackslash \texttt{raggedbottom}}
Some text before the box.
Some text before the box.
Some text before the box.
Some text before the box.
\begin{tcolorbox}[title=My first box, colframe=red]
\lipsum[1]
\end{tcolorbox}
Some text after the box.
Some text after the box.
Some text after the box.
Some text after the box.
\begin{tcolorbox}[title=My second box, colframe=green]
\lipsum[1]
\end{tcolorbox}
\end{document}

输出为:

在此处输入图片描述

选择其中一个取决于个人喜好,或者取决于您必须遵循的印刷惯例。

相关内容