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.

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?

share|improve this question
1  
Question2: according to the package author, this is impossible with the current version: see mdframed nested frametitle bug. –  Gonzalo Medina Apr 19 '12 at 22:16
    
Do you need page breaking for your "child"? –  Marco Daniel Apr 20 '12 at 9:12
    
@MarcoDaniel yes, it is a useful feature of mdframed which I do not want to miss. The content of child frame may be long flowing to the next page. Moreover, we do not know where the parent frame starts, maybe it's the bottom of page; thus, child can continue to the next page, –  All Apr 20 '12 at 11:40
add comment

1 Answer 1

up vote 4 down vote accepted

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

share|improve this answer
    
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. –  All 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. –  All 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. –  All Apr 20 '12 at 13:07
show 3 more comments

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.