# framed multicolumns

I would like to have:

• two columns (e.g. with multicol)
• framed with title
• can handle pagebreaks
• can handle twoside mode of book-class

since mdframed does not support multicol and according to the author he "has no idea how to implement it" (Two columns within mdframed frame), I started to think about how I can get this feature.

1) I could use multicol.str as base and try to add a frame. properly, this could be a good solution, but the implementation would go beyond my skills.

2) so I started to "hack" something with TikZ on the base of this http://www.mrunix.de/forums/showpost.php?p=313183&postcount=11 post.

here is my current state:

\documentclass[paper=a4,pagesize,twoside,BCOR8mm,DIV16]{scrbook}

\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{multicol}
\usepackage{lipsum}

\usepackage{tikz}

\newenvironment{Quote}%
{\begin{list}{}%
{\setlength\leftmargin{0.5\multicolsep}\setlength\rightmargin{\leftmargin}}%
\item[]\ignorespaces}%
{\end{list}%
}

%command for a box without a page break
%two arguments: title, content
\newcommand\IBox[2]{\noindent%
\begin{tikzpicture}[line width=1pt]
\pgfmathparse{\textwidth-\pgflinewidth-\multicolsep}
\node(N)[preaction={fill,opacity=0.03}]%
[draw,text width=\pgfmathresult pt,text justified,inner sep=0.5\multicolsep,outer sep=0pt,inner ysep=\multicolsep]%
{
\vspace*{1.0\baselineskip}
\begin{multicols}{2}#2%
\vspace*{-3.5\baselineskip} \end{multicols}%
};
\path (N.north west)+(1,0)node[draw,fill=white,anchor=west,rectangle,rounded corners=2mm]{#1};
\end{tikzpicture}
}

%command for a box with exact one a page break from odd to even page
%one optional argument: length correction of the box on the first page
%two obligatory arguments: title, content
\newcommand\IBoxOE[3][1pt]{\noindent%
\begin{tikzpicture}[remember picture, overlay,line width=1pt]
\pgfmathsetlengthmacro\x{1in-\hoffset-\oddsidemargin+\textwidth-26\pgflinewidth}
\path(current page.north west)+(\x,-\y)coordinate(B);
\coordinate(O)at (0.5\pgflinewidth,-0.5\pgflinewidth);
\fill[opacity=0.03](O)rectangle(B);
\draw(B-|O)--(O)-|(B)--(B);
\path (O)+(1,0)node[draw,fill=white,anchor=west,rectangle,rounded corners=2mm]{#2};
\end{tikzpicture}%
\begin{Quote}%
\begin{multicols}{2}#3\end{multicols}%
\end{Quote}%
\vspace*{-2\baselineskip}%
\begin{tikzpicture}[remember picture, overlay,line width=1pt]
\pgfmathsetlengthmacro\x{1in+\hoffset+\evensidemargin+\textwidth-0.5\pgflinewidth}
\path(current page.north west)+(\x,-\y)coordinate(B);
\coordinate(O)at (0.5\pgflinewidth,0.5\pgflinewidth);
\fill[opacity=0.03](O)rectangle(B);
\draw(B-|O)--(O)-|(B)--(B);
\end{tikzpicture}
}

%command for a box with exact one a page break from even to odd page
%one optional argument: length correction of the box on the first page
%two obligatory arguments: title, content
\newcommand\IBoxEO[3][1pt]{\noindent%
\begin{tikzpicture}[remember picture, overlay,line width=1pt]
\pgfmathsetlengthmacro\x{1in-\hoffset-\evensidemargin+\textwidth-0.5\pgflinewidth}
\path(current page.north west)+(\x,-\y)coordinate(B);
\coordinate(O)at (0.5\pgflinewidth,-0.5\pgflinewidth);
\fill[opacity=0.03](O)rectangle(B);
\draw(B-|O)--(O)-|(B)--(B);
\path (O)+(1,0)node[draw,fill=white,anchor=west,rectangle,rounded corners=2mm]{#2};
\end{tikzpicture}%
\begin{Quote}%
\begin{multicols}{2}#3\end{multicols}%
\end{Quote}%
\vspace*{-2\baselineskip}%
\begin{tikzpicture}[remember picture, overlay,line width=1pt]
\pgfmathsetlengthmacro\x{1in+\hoffset+\oddsidemargin+\textwidth-0.5\pgflinewidth}
\path(current page.north west)+(\x,-\y)coordinate(B);
\coordinate(O)at (0.5\pgflinewidth,0.5\pgflinewidth);
\fill[opacity=0.03](O)rectangle(B);
\draw(B-|O)--(O)-|(B)--(B);
\end{tikzpicture}
}

\begin{document}

\IBox{no page break}{
\lipsum[1-2]
}

\IBoxOE{page break: odd even}{
\lipsum[1-6]
}

\IBoxEO{page break: even odd}{
\lipsum[1-5]
}

\end{document}


unfortunately it hast some drawbacks:

• it needs two runs (but I can life with this)
• different commands for boxes with and without page break are needed
• different commands for page breaks for odd to even and even to odd pages are needed
• can not handle more then one page break (would need new commands for it; but I do not plan to uses such large boxes)

Are there any other alternatives I have overlooked? BTW, I'm using LuaLaTeX, maybe one can use some possibilities of Lua.

I also have tryed boites and framed, but both can does not break pages when multicol is used.

example for boites:

\documentclass[towpages]{book}
\usepackage{boites,boites_exemples}
\usepackage{multicol}
\usepackage{lipsum}

\begin{document}
\begin{boiteepaisseavecuntitre}{ Coucou ! }
\begin{multicols}{2}
\lipsum[1-8]
\end{multicols}
\end{boiteepaisseavecuntitre}
\end{document}

-
–  David Carlisle Sep 14 '13 at 21:18
@DavidCarlisle Great, thanks. When I use your code I have problems with the margins: tex.stackexchange.com/questions/136434/… –  susis strolch Oct 4 '13 at 15:19