# Suppress top skip between own frame environment and itemize

I need to typset a book with a given definition of {itemize} and I added a {framed} environment by using mdframed. If the first line inside {framed} is normal text everything is fine

but if it starts with an {itemize} environment there is some extra space I can’t delete.

The skip before the end of the frame is okay in both cases. If I comment out the redefinition of {itemize} the skips are also okay.

Code

\documentclass{scrartcl}

\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}

\makeatletter
\renewenvironment{itemize}{%
\begin{list}{\labelitemi}{%
\setlength{\itemsep}{\z@}%
\setlength{\parsep}{\z@}%
\setlength{\parindent}{1em}%
\setlength{\labelwidth}{\parindent}
\setlength{\labelsep}{0pt}
\setlength{\leftmargin}{\labelwidth+\labelsep}%
\def\makelabel##1{\rlap{\normalfont\nobreak ##1}\hss}
}%
}{%
\end{list}
}

\usepackage[framemethod=TikZ]{mdframed}
\usepackage{xparse}% doesn't work without this package ... ???
\newenvironment{framed}{%
\begin{mdframed}[%
skipabove=\baselineskip plus 2pt minus 1pt,
skipbelow=\baselineskip plus 2pt minus 1pt,
middlelinewidth=0.5pt,
splittopskip=8pt,
splitbottomskip=2pt,
innertopmargin=9.39749pt,
innerbottommargin=9.39749pt,
innerleftmargin=9.39749pt,
innerrightmargin=9.39749pt,
]%
}{%
\end{mdframed}
}
\makeatother

\usepackage{blindtext}

\begin{document}
\blindtext
\begin{framed}
\blindtext
\end{framed}
\blindtext
\begin{framed}
\blinditemize
\end{framed}
\end{document}


I tried to compare the new definition with the one from source2e but I didn’t find the difference causing the extra space. I found the \@minipagetrue trick but that doesn’t help.

Question
How can I tell {itemize} to not insert space if it starts a frame?

-

Two comment signs were missing, and this created spurious spaces.

\documentclass{scrartcl}

\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}

\makeatletter
\renewenvironment{itemize}{%
\begin{list}{\labelitemi}{%
\setlength{\itemsep}{\z@}%
\setlength{\parsep}{\z@}%
\setlength{\parindent}{1em}%
\setlength{\labelwidth}{\parindent}% <-- THIS ONE WAS MISSING
\setlength{\labelsep}{0pt}% <-- AND THIS ONE, TOO
\setlength{\leftmargin}{\labelwidth+\labelsep}%
\def\makelabel##1{\rlap{\normalfont\nobreak ##1}\hss}% <-- Shouldn't harm
}%
}{%
\end{list}
}

\usepackage[framemethod=TikZ]{mdframed}
\usepackage{xparse}% doesn't work without this package ... ???
\newenvironment{framed}{%
\begin{mdframed}[%
skipabove=\baselineskip plus 2pt minus 1pt,
skipbelow=\baselineskip plus 2pt minus 1pt,
middlelinewidth=0.5pt,
splittopskip=8pt,
splitbottomskip=2pt,
innertopmargin=9.39749pt,
innerbottommargin=9.39749pt,
innerleftmargin=9.39749pt,
innerrightmargin=9.39749pt,
]%
}{%
\end{mdframed}
}
\makeatother

\usepackage{blindtext}

\begin{document}
\blindtext
\begin{framed}
\blindtext
\end{framed}
\blindtext
\begin{framed}
\blinditemize
\end{framed}
\end{document}

-
Thank you very much. I never thought of that O:-) –  Tobi Jan 1 '12 at 23:42