6

I tried to create a child frame inside a parent frame by mdframed as

\documentclass{article}
\usepackage{mdframed}
\usepackage{lipsum}

\begin{document}

\begin{mdframed}[frametitlerule=true,frametitlerulewidth=1pt,frametitle=Parent]
\begin{mdframed}[frametitlerule=true,frametitlerulewidth=1pt,userdefinedwidth=150pt,align=right,frametitle=Child]
\lipsum[1]
\end{mdframed}
\lipsum
\end{mdframed}

\end{document}

enter image description here

Question1: How to wrap text around the child frame? Filling the empty space on the left with the text of parent frame.

Question2: The child frame title will conquer the parent frame title. Thus, we will not have the parent frame title, but an induced copy of the child frame title. How to keep the frame titles independently?

lockstep
  • 250,273
Googlebot
  • 4,035

1 Answers1

4

To both requests I have to answer with no.

The first one can be implemented but I'm not able to do the second one. I have no idea how to solve the following problem.

To illustrate my problem here is an example:

\documentclass[12pt]{article}
\usepackage{kantlipsum}
\begin{document}
\newbox\mybox
\setbox\mybox=\vbox{\kant[1]}
\setbox\mybox\vsplit\mybox to 3cm
\box\mybox

\setbox\mybox=\vbox{\vbox{\kant[1]}}
\setbox\mybox\vsplit\mybox to 3cm
\box\mybox
\end{document}

EDIT: If you don't need a page break inside the nested mdframed environment you can use the following code which uses the package cutwin.

\documentclass[demo]{article}
\usepackage{mdframed}
\usepackage{lipsum}
\usepackage[demo]{graphicx} 
%\usepackage{wrapfig}
\usepackage{twoopt}
\usepackage{cutwin}
\opencutright
\begin{document}

\section{Text}

\def\windowpagestuff{\par%
\begin{mdframed}[frametitlerule=true,frametitlerulewidth=1pt,userdefinedwidth=150pt,align=right,frametitle=Child,nobreak]
\lipsum[3]
\end{mdframed}%
%\rule[2cm]{2cm}{8cm}%
}
\begin{mdframed}[frametitlerule=true,frametitlerulewidth=1pt,frametitle=Parent,]
Text
\begin{cutout}{2}{150pt}{0pt}{30}
\let\par\relax\lipsum[2]\lipsum[1]
\end{cutout}
\lipsum
\end{mdframed}
\end{document}

The result of the first page will be

enter image description here

egreg
  • 1,121,712
Marco Daniel
  • 95,681
  • I understand the situation. I hope to find a solution for this, making mdframed more powerful. This is of particular importance, as this behavior is practically missed in all latex packages (no practical solution). What is your solution to build child frames without pagebreak? This is what wrapfig does, but I prefer mdframed as it has better features to play on. – Googlebot Apr 20 '12 at 11:55
  • @Ali: Do you want to know a solution where no page break is needed for the child? Do I understand you correct? – Marco Daniel Apr 20 '12 at 11:57
  • Yes, it is better than nothing. I am currentling using minipage within wrapfig to do so. It is better to do everything with mdframed as the parent is already mdframed. – Googlebot Apr 20 '12 at 12:01
  • @Ali: I edited my answer. – Marco Daniel Apr 20 '12 at 12:39
  • Thanks, it's an interesting solution, but I doubt if it can be practical. You are indeed attaching two independent frames with cutwin; not dealing with the child frame within the parent framework. This is not suitable for complicated documents having several mdframed parent frames. What I like about mdframed is that it somehow keeps the frame separate from the reset of the document. – Googlebot Apr 20 '12 at 13:07
  • @Ali: There is an other approach using \parshape and a modification of some internals of mdframed. But this isn't such simple that I can solve it in 5 minutes ;-) – Marco Daniel Apr 20 '12 at 13:12
  • @Ali: See: http://tex.stackexchange.com/questions/23402/mdframed-and-wrapfig – Marco Daniel Apr 20 '12 at 13:26