3

I have an mdframed environment and i want another frame, just with background color, inside it but i don't wish to have the above title inherited.

That's why i used the shaded environment. My problem is that i can't align the inner shaded box with the inner lines of the outer.

Is there a way that i can fit both boxes perfectly, with no whitespace and no overlaps of one on top of the other?

\documentclass[9pt,twoside,openright,showtrims]{memoir} 
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{mathspec,xltxtra}
\usepackage{color, colortbl}
\usepackage[framemethod=TikZ]{mdframed}
\colorlet{shadecolor}{gray!10}

\newcounter{solved}[chapter]
\renewcommand{\thesolved}{\thechapter.\arabic{solved}}
\newenvironment{solved}[1][]{%
\refstepcounter{solved}
\begin{mdframed}[%
    frametitle={\textbf{\Large{SOLVED EXAMPLE} \thesolved}\ \\ #1},
    frametitlerule=true,
    frametitlerulewidth=1pt,
    frametitlerulecolor=black,
    innertopmargin=-0.7em,%
    innerleftmargin=0.4em,%,
    hidealllines=true,leftline=true,
    %frametitlebackgroundcolor=gray!70,
    linewidth=10pt,
    linecolor=gray!80,
    %fontcolor=white,%
    %backgroundcolor=gray!10
]%
}{%
\end{mdframed}
}

\begin{document}
\begin{solved}[Lorem ipsum dolor sit amet]
\begin{shaded}
Solve this one

\begin{enumerate}
 \item
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.  
 \item
 Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
\item
Velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
\end{enumerate}
\end{shaded}

\b{\Large{SOLUTION}}

\noindent
Velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
\end{solved}
\end{document}
3

You can use another mdframed for the inner shaded area. For this define a style like

\mdfdefinestyle{style2}{frametitle={},innertopmargin=5pt,linecolor=blue!20,%
             linewidth=2pt,hidealllines=true,topline=true,backgroundcolor=gray!20}

and apply it to the inner mdframed environment.

\documentclass[9pt,twoside,openright,showtrims]{memoir}
\usepackage{amsmath,amssymb,amsfonts}
%\usepackage{mathspec,xltxtra}
\usepackage{color, colortbl}
\usepackage[framemethod=TikZ]{mdframed}
\colorlet{shadecolor}{gray!10}

\newcounter{solved}[chapter]
\renewcommand{\thesolved}{\thechapter.\arabic{solved}}
\newenvironment{solved}[1][]{%
\refstepcounter{solved}
\begin{mdframed}[%
    frametitle={\hspace{0.5em}\textbf{\Large SOLVED EXAMPLE \thesolved}\ \\ \hspace*{0.5em}#1},
    frametitlerule=true,
    frametitlerulewidth=1pt,
    frametitlerulecolor=black,
    innertopmargin=0em,%
    innerleftmargin=0em,%,
    innerrightmargin=0em,
    hidealllines=true,leftline=true,
    %frametitlebackgroundcolor=gray!70,
    linewidth=10pt,
    linecolor=gray!80,
    %fontcolor=white,%
    %backgroundcolor=gray!10
]%
}{%
\end{mdframed}
}

\mdfdefinestyle{style1}{frametitle={},innertopmargin=0pt,
             linewidth=0.5em,linecolor=white,hidealllines=true,rightline=true,leftline=true,
             }
\mdfdefinestyle{style2}{frametitle={},innertopmargin=5pt,innerrightmargin=0.5em,%
             linewidth=2pt,linecolor=gray!20,hidealllines=true,topline=true,leftline=true,
             linewidth=0.4em,backgroundcolor=gray!20}

\begin{document}
\begin{solved}[Lorem ipsum dolor sit amet]
\begin{mdframed}[style=style2]
Solve this one

\begin{enumerate}
 \item
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
 \item
 Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
\item
Velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
\end{enumerate}
\end{mdframed}

\begin{mdframed}[style=style1]
{\bfseries\Large{SOLUTION}}

\noindent
Velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
\end{mdframed}
\end{solved}
\end{document}

enter image description here

3
  • thanks, i was also wondering if i could eliminate the white space around the inner box – S.M Apr 28 '15 at 13:29
  • @SofiaMouseti Please see the edit. If you need a tcolorbox variant, let me know. – user11232 Apr 28 '15 at 16:08
  • thank u, but the problem is that everytime the outer 'solved' example is very big and has to break in multiple pages, it shows the first frame and then it breaks the second inner frame (the one with the solution) in a new page – S.M Apr 30 '15 at 7:40

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.