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.

Hello everybody out there using TeX,

Is there a possibility to draw a frame over a columnbreak when using for example the multicol package?

I've already tried several possibilities and done extensive websearch. Interestingly, there seem to be several people having this problem, but there's no solution available in the web.

Unfortunately, the framed and mdframed package don't work with the multicol package according to their manuals.

The listings package, seems to have a bug: it does split text on different columns correctly, but the colour highlights wrong sections:

\documentclass[landscape,a4paper]{article}
\usepackage{color,lipsum,listings,multicol}
\lstset{%
  backgroundcolor=\color{green},
  escapechar={\%}
}
\begin{document}
   \begin{multicols*}{4}
     \colorbox{green}{
     \begin{lstlisting}
       %
       \section{First section}
       \lipsum
       %
     \end{lstlisting}
     }
   \end{multicols*}
\end{document}

I would be very grateful for any hints towards a solution.

One additional step in the right direction might be the boites package:

\documentclass[a0,landscape]{a0poster}
\usepackage{boites,color,lipsum,multicol}
\begin{document}
\begin{multicols}{4}
\begin{breakbox}
\lipsum
\end{breakbox}
\end{multicols}
\end{document}

But this does not allow for background colouring using pdflatex.

share|improve this question
1  
What do you mean with "draw a frame over a columnbreak"? –  Keks Dose Jun 18 '12 at 14:49
    
I believe the question is related to the \colorbox{} - how to make it automatically split between columns instead of being in it's total height either at the end of column 1 or at the top of column 2. (I do have the same problem.) Or more generic: how to have a multi-line box with border or background color split in half when necessary. –  TeXter Jun 18 '12 at 18:58
    
Maybe tex.stackexchange.com/questions/59340/… is what you are looking for. –  TeXter Jun 22 '12 at 12:19

1 Answer 1

enter image description here

\documentclass[landscape,a4paper]{article}
\usepackage{color,lipsum,multicol}
\advance\columnsep3pt
\makeatletter
\def\foo#1\full@width#2#3!!{
\def\page@sofar{#1\full@width{%
\vrule
{\color{green}\leaders\vrule\hskip\full@width}\kern-\full@width
\kern3\p@
#2%
 \kern3\p@\vrule}%
#3}}
\expandafter\foo\page@sofar!!

\makeatother

\begin{document}

\lipsum[1]

   \begin{multicols*}{4}
       \section{First section}
       \lipsum
   \end{multicols*}

\lipsum[2]

\end{document}

Werner commented in chat that this answer was less than completely documented.

\page@sofar is the multicol internal macro responsible for assembing the column boxes that have been produced into a row across the page together with inter-column rules and space. this just inserts a black rule and some space either side. (The \intercolumnsep parameter is increased a bit to make space for these) and a full width green rule is added at the start of the box, then negative space inserted so the column boxes come on top.

share|improve this answer
    
why not patch a little bit more "high-level" using etoolbox or so? very efficient above, but probably not understandable to many without a lot of thinking. –  Frank Mittelbach Sep 23 '13 at 21:11
    
@FrankMittelbach feel free to edit my answer:-) I'd have to check the etoolbox patch syntax but can write the delimited argument form in my sleep. But yes it would be better, I should try harder:-) –  David Carlisle Sep 23 '13 at 21:14
    
it wouldn't hurt if you do :-) it is easy enough ... but I know the feeling ... had a copy of the code lying around for cut and paste from one answer to the next for a while –  Frank Mittelbach Sep 23 '13 at 21:16

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.