3
\documentclass[a4paper,10pt]{article}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{lipsum}
\usepackage{multicol}

\mdfdefinestyle{graybox}{
    splittopskip=0,%
    splitbottomskip=0,%
    frametitleaboveskip=0,
    frametitlebelowskip=0,
    skipabove=0,%
    skipbelow=0,%
    leftmargin=0,%
    rightmargin=0,%
    innertopmargin=2mm,%
    innerbottommargin=2mm,%
    roundcorner=2mm,%
    backgroundcolor=gray!20}


\begin{document}

\begin{mdframed}[style=graybox]
\begin{multicols}{2}
\lipsum[1]
\columnbreak
\lipsum[2]
\end{multicols}
\end{mdframed}

\end{document}

Result:

enter image description here

How do I remove that top margin inside the mdframe?

Already tried this but doesn't work:

\begin{document}
\begin{mdframed}[style=graybox]
\begin{multicols}{2}
\vskip -2\baselineskip
\lipsum[1]
\columnbreak
\vskip -2\baselineskip
\lipsum[2]
\end{multicols}
\end{mdframed}
\end{document}
6

You need to adjust the \multicolsep variable:

Sample output

\documentclass[a4paper,10pt]{article}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{lipsum}
\usepackage{multicol}

\mdfdefinestyle{graybox}{
    splittopskip=0,%
    splitbottomskip=0,%
    frametitleaboveskip=0,
    frametitlebelowskip=0,
    skipabove=0,%
    skipbelow=0,%
    leftmargin=0,%
    rightmargin=0,%
    innertopmargin=2mm,%
    innerbottommargin=2mm,%
    roundcorner=2mm,%
    backgroundcolor=gray!20}


\begin{document}

\begin{mdframed}[style=graybox]
\setlength{\multicolsep}{2pt}
\begin{multicols}{2}
\lipsum[1]
\columnbreak
\lipsum[2]
\end{multicols}
\end{mdframed}

\end{document}

From the documentation of multicol:

As its first action, the multicols environment measures the current page to determine whether there is enough room for some portion of multicolumn output. This is controlled by the ⟨dimen⟩ variable \premulticols which can be changed by the user with ordinary LATEX commands. If the space is less than \premulticols, a new page is started. Otherwise, a \vskip of \multicolsep is added.

\multicolsep is kicking in as multicols is the first thing in the environment. By default \multicolsep is 12pt plus 4pt minus 3pt, which is the same order of magnitude as the baselineskip/blank line in a standard document.

| improve this answer | |

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.