0

When using mdframed, there is an empty last line before page breaks as follows

|----------------------------|
| 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 |
|----------------------------|

How to fill this last line of the page? Here is a 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}
2

The extra space below is splitbottomskip. The documentation says the default is 0pt, but that is not true: it is 10pt. And so is splittopskip but I think this is measured from the baseline of the first line to the top of the frame, so that seems reasonable.

So the solution is to add splitbottomskip=0pt to \mdfsetup.

1

With tcolorbox you can play with topsep at break and bottomsep at break to adjust these spaces.

Your example adapted to tcolorbox could be:

\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}

Intial tabular has been declared with a tcolorbox with tabularx* option and also new mypar boxes with a mandatory parameter for box title has been defined. The result looks like:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.