Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

normal text

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

itemize

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?

share|improve this question
add comment

1 Answer 1

up vote 7 down vote accepted

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}
share|improve this answer
    
Thank you very much. I never thought of that O:-) –  Tobi Jan 1 '12 at 23:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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