9

This question is a follow-up question to: Access mdframed node coordinates with TikZ?

@MarcoDaniel: Awesome package (mdframed)! Nice clean code, too.

@Tobi: I really like your new excursus environment! However, there is an issue when it splits on pages: the first box (\mdf@putbox@first) is sent to the following page. Using your previous code:

\documentclass{scrartcl}

\usepackage{tikz}
   \usetikzlibrary{calc,arrows}
\usepackage{etoolbox}
\usepackage[framemethod=tikz]{mdframed}

\tikzstyle{excursus arrow}=[%
   line width=4pt,
   draw=blue,
   rounded corners=2ex
]
\tikzstyle{excursus head}=[%
   fill=white,
   font={\bfseries\sffamily},
   text=blue,
   anchor=base,
]

\makeatletter
\newcommand{\drawexcursusarrow}{%
   \patchcmd{\mdf@putbox@single}{\mdfcreateextratikz}{
      \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
      \path let \p1=(Q), \p2=(O) in (\x1,{(\y1-\y2)/2}) coordinate (M);
      \path [excursus arrow, round cap->]
         ($(O)+(5em,0ex)$) -| (M) |- %
         ($(Q)+(6em,0ex)$) .. controls +(0:16em) and +(185:6em) .. %
         ++(23em,2ex);
      \node [excursus head] at ($(Q)+(4.5em,-2pt)$) {Excursus};
   }{}{}%
   \patchcmd{\mdf@putbox@first}{\mdfcreateextratikz}{
      \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
      \path [excursus arrow,->]
         (O) |- %
         ($(Q)+(6em,0ex)$) .. controls +(0:16em) and +(185:6em) .. %
         ++(23em,2ex);
      \node [excursus head] at ($(Q)+(4.5em,-2pt)$) {Excursus};
   }{}{}%
   \patchcmd{\mdf@putbox@second}{\mdfcreateextratikz}{
      \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
      \path [excursus arrow,round cap-]
         ($(O)+(5em,0ex)$) -| (Q);
   }{}{}%
   \patchcmd{\mdf@putbox@middle}{\mdfcreateextratikz}{
      \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
      \path [excursus arrow]
         (O) -- (Q);
   }{}{}%
}
\makeatother
\newmdenv[%
   middlelinewidth=24pt,
   middlelinecolor=white,
   rightline=false,
   innertopmargin=0ex,
   innerbottommargin=0ex,
   innerrightmargin=2pt,
   innerleftmargin=0ex,
   leftmargin=-11pt,
   skipabove=12pt,
   skipbelow=-1pt,%=12-24/2-2/2
   settings=\drawexcursusarrow,
]{excursus}

\usepackage{lipsum}

\begin{document}

\lipsum[3]
\begin{excursus}
   \lipsum[1]
\end{excursus}
\lipsum[3]
%\vspace*{-2\baselineskip}
\begin{excursus}   %% Added to illustrate the splitting problem
   \lipsum[1-2]
\end{excursus}
\lipsum[3]

\end{document}

You can uncomment the \vspace*{...} to see the \mdf@putbox@first reappear in the appropriate page, but it now overlaps the previous text.

My guess is that the added height from the top excursus arrow (and title) is not accounted for in the mdframed algorithm to split over pages, so the total height of \mdf@putbox@first now exceeds the available vertical space remaining on the page.

Does that sound right and is there a way to fix it?

7
  • I can't understand the problem? Of course the package doesn't know the height of the arrow but therefor you have provided the correct width by middlelinewidth. Commented Apr 5, 2012 at 19:13
  • Thank you @MarcoDaniel, that indeed solves the issue! It's actually my fault: I had added the hidealllines=true option to my test file, which of course is inconsistent with the middlelinewidth=24pt option. I have changed middlelinecolor=green to middlelinecolor=white. Is there a way to make the line color transparent instead? Commented Apr 10, 2012 at 13:51
  • @MarcoDaniel: Is that the answer then? Commented Apr 10, 2012 at 14:52
  • @PeterGrill I created an example of this environment in the version 1.5. Commented Apr 10, 2012 at 17:20
  • @MarcoDaniel: Excellent! But I still think you should post an answer here, and show the code snippets so that this question can be "answered". Commented Apr 10, 2012 at 17:33

1 Answer 1

9

I uploaded version 1.5 and added an exampple of the excurs-environment. You can find the example in the file mdframed-example-texsx.pdf (Example 5).

The environment can be defined with the following settings:

\usetikzlibrary{calc,arrows}

Needed for the design (not mdframed related)

Define the style of the lines and the arrows (not mdframed related)

\tikzset{
   excursus arrow/.style={%
    line width=2pt,
    draw=gray!40,
    rounded corners=2ex,
   },
   excursus head/.style={
    fill=white,
    font=\bfseries\sffamily,
    text=gray!80,
    anchor=base west,
   },
}

Define the new environment with the new keys of version 1.5: singleextra, firstextra, middleextra and secondextra

\mdfdefinestyle{digressionarrows}{%
  singleextra={%
   \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
   \path let \p1=(Q), \p2=(O) in (\x1,{(\y1-\y2)/2}) coordinate (M);
   \path [excursus arrow, round cap-to]
   ($(O)+(5em,0ex)$) -| (M) |- %
   ($(Q)+(12em,0ex)$) .. controls +(0:16em) and +(185:6em) .. %
   ++(23em,2ex);
   \node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {Digression};},
  firstextra={%
   \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
   \path [excursus arrow,-to]
   (O) |- %
   ($(Q)+(12em,0ex)$) .. controls +(0:16em) and +(185:6em) .. %
    ++(23em,2ex);
   \node [excursus head] at ($(Q)+(2.5em,-2pt)$) {Digression};
  },
  secondextra={%
   \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
   \path [excursus arrow,round cap-]
   ($(O)+(5em,0ex)$) -| (Q);
  },
  middleextra={%
   \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
   \path [excursus arrow](O) -- (Q);
  },
  middlelinewidth=2.5em,middlelinecolor=white,
  hidealllines=true,topline=true,
  innertopmargin=0.5ex,
  innerbottommargin=2.5ex,
  innerrightmargin=2pt,
  innerleftmargin=2ex,
  skipabove=0.87\baselineskip,
  skipbelow=0.62\baselineskip,
}

Important are the lines:

  middlelinewidth=2.5em,middlelinecolor=white,
  hidealllines=true,topline=true,

First I removed all lines drawn by mdramed and add only the first line. The first line with line color white is needed. In this way mdframed knows the height of the excurs-lines and can calculate the correct splitting point.

With these settings you get:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .