3

I used the Excursus environment as a template to create my own box like this:

\usepackage[style=1,leftmargin=0pt,rightmargin=0pt,framemethod=TikZ]{mdframed}
\newenvironment{boxtype1}{%

\begin{mdframed}%

[linewidth=.5,margin=8.5,backgroundcolor=gray!2,linecolor=red,fontcolor=black,roundcorner=10pt, middlelinewidth=2pt]%

\fontsize{12}{14}\sffamily\selectfont%
}{\end{mdframed}}

Works perfectly nice. However, would there be a way to automatically close the box at a page break and then open it new on the next one? If it would even be possible to have a "Excursus X continued" on each page that would be perfect.

Thanks

Philipp

  • Please provide a complete, compilable example. That is much more useful than a mere fragment of code and will encourage people to answer your question! – cfr Nov 30 '14 at 17:51
  • everyline [untested since no Minimum Working Example provided] – cfr Nov 30 '14 at 17:55
2

You can use the everyline=true option so that all parts of the mdframed get the whole frame. Using middleextra and secondextra, you can add material for the continuing parts of the mdframed. In the example below I added "Excursus (Cont.)" at the upper left part of the frame in the continuation parts.

enter image description here

The code:

\documentclass{article}
\usepackage[a5paper]{geometry}% just for the example
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{lipsum}

\newenvironment{boxtype1}
  {%
  \begin{mdframed}[
    linewidth=.5,
    everyline=true,
    %margin=8.5,
    backgroundcolor=gray!2,
    linecolor=red,
    fontcolor=black,
    roundcorner=10pt,
    middlelinewidth=2pt,
    splittopskip=25pt,
    secondextra={
      \node[
        overlay,
        fill=white,
        anchor=west,
        font=\sffamily\large,
        inner xsep=10pt
      ] at ([xshift=10pt]O|-P) {Excursus (Cont.)};
      },
    middleextra={
      \node[
        overlay,
        fill=white,
        anchor=west,
        font=\sffamily\large,
        inner xsep=10pt
      ] at ([xshift=10pt]O|-P) {Excursus (Cont.)};
      }
  ]%
  \fontsize{12}{14}\sffamily\selectfont%
  }
  {\end{mdframed}}

\begin{document}

\lipsum[1-2]
\begin{boxtype1}
\lipsum[1-4]
\end{boxtype1}
\lipsum[2]

\end{document}
  • Works! And looks awesome. Thanks. One question though, is there a way to control the bottom boundary of the box? The lower part of the letters touch the red line. Or is this my footer, which needs to be changed? – user2334921 Nov 30 '14 at 21:30
  • @user2334921 You're welcome! Regarding your question, you can control the separation between text and the bottom line using innerbottommaring, as in innerbottommaring=40pt. There's also splitbottomskip for the split components of the frame. If this doesn't solve your problem, I'll need to see some minimal, yet complete code illustrating the problem; otherwise, no effective advise can be provided. – Gonzalo Medina Dec 1 '14 at 1:00
  • Thanks again @GonzaloMedina. The splitbottomskip does the trick. Sorry for not providing an example. I will do this next time. Cheers Philipp – user2334921 Dec 1 '14 at 9:59

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.