使用 mdframed 时,分页符前有一个空白的最后一行,如下所示
|----------------------------|
| xxxx xxx xxx xxxx xxx xxxx |
| xxxx xxx xxx xxxx xxx xxxx |
| |
<page break>
| xxxx xxx xxx xxxx xxx xxxx |
| xxxx xxx xxx xxxx xxx xxxx |
|----------------------------|
如何填写页面的最后一行?以下是 MWE
\documentclass[10pt]{article}
\usepackage[margin=2cm,a4paper]{geometry}
\usepackage{mdframed}
\mdfsetup{skipabove=0pt,skipbelow=0pt,topline=false,
innertopmargin=2pt,innerbottommargin=2pt,innerleftmargin=2pt,innerrightmargin=2pt}
\usepackage{lipsum}
\usepackage{colortbl}
\definecolor{gray}{gray}{0.9}
\begin{document}
\noindent
\begin{tabular}{|p{8mm}|p{4cm}|p{8cm}|p{2.45cm}|}\hline
\rowcolor{gray} \bf No. & \bf Title & \bf WP Leader & \bf Months \\\hline
WP1 & Title & Partner & m6--m45 \\\hline
\end{tabular}
\vspace*{-2pt}
\begin{mdframed}
\textbf{Objectives}\quad
\lipsum[1-3]
\end{mdframed}%
\begin{mdframed}
\textbf{Description of Work and Role of Partners}\quad
\lipsum[4-7]
\end{mdframed}%
\begin{mdframed}
\textbf{Description of Deliverables}\quad
\lipsum[4-8]
\end{mdframed}%
\vspace{2pt}
\noindent
\begin{tabular}{|p{8mm}|p{4cm}|p{8cm}|p{2.45cm}|}\hline
\rowcolor{gray} \bf No. & \bf Title & \bf WP Leader & \bf Months \\\hline
WP2 & Title & Partner & m6--m45 \\\hline
\end{tabular}
\vspace*{-2pt}
\begin{mdframed}
\textbf{Objectives}\quad
\lipsum[1-3]
\end{mdframed}%
\begin{mdframed}
\textbf{Description of Work and Role of Partners}\quad
\lipsum[4-7]
\end{mdframed}%
\begin{mdframed}
\textbf{Description of Deliverables}\quad
\lipsum[4-8]
\end{mdframed}%
\end{document}
答案1
下面的额外空间是splitbottomskip
。文档说默认值是0pt
,但事实并非如此:它是10pt
。所以是splittopskip
但我认为这是从第一行的基线到框架顶部测量的,所以这似乎是合理的。
因此解决方案是添加splitbottomskip=0pt
到\mdfsetup
。
答案2
您tcolorbox
可以玩耍topsep at break
并bottomsep at break
调整这些空间。
您所适应的示例tcolorbox
可能是:
\documentclass[10pt]{article}
\usepackage[margin=2cm,a4paper]{geometry}
\usepackage{array,tabularx}
\usepackage[table]{xcolor}
\usepackage[most]{tcolorbox}
\tcbset{sharp corners, size=tight, boxsep=2pt,
colback=white, boxrule=1pt,
before skip=-1pt,
after skip=0pt,
}
\usepackage{lipsum}
\usepackage{colortbl}
\definecolor{gray}{gray}{0.9}
\newtcolorbox{mypar}[2][]{%
enhanced,
breakable,
fonttitle=\bfseries,
coltitle=black,
detach title,
title={#2},
before upper={\tcbtitle\quad},
bottomsep at break=-1mm,
topsep at break=-1mm,
#1
}
\begin{document}
\noindent
\begin{tcolorbox}[tabularx*={\arrayrulewidth1pt}{p{8mm}|p{4cm}|p{8cm}|X},
before upper app={\rowcolor{gray}}]
\textbf{No.} & \textbf{Title} & \textbf{WP Leader} & \textbf{Months}\\\hline
WP1 & Title & Partner & m6--m45
\end{tcolorbox}%
\begin{mypar}{Objectives}
\lipsum[1-3]
\end{mypar}%
\begin{mypar}{Description of Work and Role of Partners}
\lipsum[4-7]
\end{mypar}%
\begin{mypar}{Description of Deliverables}
\lipsum[4-8]
\end{mypar}%
\vspace{2pt}
\noindent
\begin{tcolorbox}[tabularx*={\arrayrulewidth1pt}{p{8mm}|p{4cm}|p{8cm}|X},
before upper app={\rowcolor{gray}}]
\textbf{No.} & \textbf{Title} & \textbf{WP Leader} & \textbf{Months}\\\hline
WP1 & Title & Partner & m6--m45
\end{tcolorbox}%
\begin{mypar}{Objectives}
\lipsum[1-3]
\end{mypar}%
\begin{mypar}{Description of Work and Role of Partners}
\lipsum[4-7]
\end{mypar}%
\begin{mypar}{Description of Deliverables}
\lipsum[4-8]
\end{mypar}%
\end{document}
tabular
已使用tcolorbox
with选项声明了Intial tabularx*
,并且mypar
已定义带有框标题强制参数的新框。结果如下所示: