2

I would like to create box inside box as the picture below :

enter image description here

Here is my code :

\documentclass[10pt,a4paper]{report}
\usepackage[margin=0.5in]{geometry}
\usepackage{amsthm,amssymb,amsfonts}
\usepackage{tikz,lipsum,lmodern}
\usepackage[most]{tcolorbox}
\usepackage[svgnames]{xcolor}

\newtcolorbox{Box1}[2][]{sidebyside,
                lower separated=false,
                colback=white,
colframe=white!20!gray,fonttitle=\bfseries,
colbacktitle=white!10!gray,enhanced,
attach boxed title to top left={xshift=1cm,
        yshift=-2mm},
title=#2,#1}

\newtcolorbox{Box2}[2][]{sidebyside,
                lower separated=false,
                colback=white!60!gray,
colframe=white!20!gray,fonttitle=\bfseries,
colbacktitle=white!10!gray,enhanced,
attach boxed title to top left={xshift=1cm,
        yshift=-2mm},
title=#2,#1}



\begin{document}

\begin{Box1}{Exemple}
 \begin{minipage}[b]{0.9\linewidth}\centering
\begin{tcolorbox}[colback=white!60!gray,colframe=white!20!gray]
On Considère une va $X$ à valeurs dans $\{1,2,3\}$ et de loi: $P\left(X=1\right)=\dfrac{1}{6}$, $P\left(X=2\right)=\dfrac{1}{3}$ $P\left(X=3\right)=\dfrac{1}{2}$.

Calculer $E\left(X\right)$ et $E\left(X^{3}\right)$ 
\end{tcolorbox}
\end{minipage}
\tcblower
On a : $E\left(X \right)=\sum_{k=1}^{3}kP\left(X=k\right)=1\dfrac{1}{6}+2\dfrac{1}{3}+3\dfrac{1}{2}=\dfrac{7}{3}$.
D'après la formule de transfert : 
\[E\left(X^3\right)=\sum_{k=1}^{3}P\left(X=k \right)=1^{3}\dfrac{1}{6}+2^{3}\dfrac{1}{3}+3^{3}\dfrac{1}{2}=\dfrac{49}{3} \]
\end{Box1}

\begin{Box2}{Méthode}
 \begin{minipage}[b]{0.6\linewidth}\centering
\begin{tcolorbox}[colback=white,colframe=white!20!gray]
Pour calculer la variance $V\left( X\right)$ d'une va $X$
\end{tcolorbox}
\end{minipage}
\tcblower
Essayer de :
\noident 
\begin{itemize}
\item Utiliser la formule : $V\left( X\right)=E\biggl(\left(X-E(x)\right)^{2}\biggr) $
\item Utiliser la formule : $V\left( X\right)=E\left( X^2\right)-\left(E\left( X^2\right)\right)^{2} $
\item Utiliser la formule : $V\left( X\right)=a^{2}V\left(Y\right)$ si $X=aY+b$
\end{itemize}
Exercice $28.1$ à $28.5$
\end{Box2}
\end{document}

which produce :

enter image description here

  • Could someone please improve my code to create the same picture as i post on top
  • I don't see the question here! – Joseph Wright Jan 13 '17 at 10:51
  • my question could you please improve my code to produce the same picture – Educ Jan 13 '17 at 10:52
3

You can use righthand ratio=<fraction> key to define right-handed part to the given <fraction> or righthand width=<width> for a fixed length

Key sidebyside align=top seam to align left side box to the top

\documentclass[10pt,a4paper]{report}
\usepackage[margin=0.5in]{geometry}
\usepackage{amsthm,amssymb,amsfonts}
\usepackage{tikz,lipsum,lmodern}
\usepackage[most]{tcolorbox}

\newtcolorbox{Box1}[2][]{sidebyside,
                lower separated=false,
                righthand ratio=0.56, % to define right-hand fraction
                colback=white,
colframe=white!20!gray,fonttitle=\bfseries,
colbacktitle=white!10!gray,enhanced,
attach boxed title to top left={xshift=1cm,
        yshift=-2mm},
title=#2,#1}

\newtcolorbox{Box2}[2][]{sidebyside,
                lower separated=false,
                righthand ratio=0.56,
                colback=white!60!gray,
colframe=white!20!gray,fonttitle=\bfseries,
colbacktitle=white!10!gray,enhanced,
attach boxed title to top left={xshift=1cm,
        yshift=-2mm},
title=#2,#1}



\begin{document}

\begin{Box1}{Exemple}
\begin{tcolorbox}[colback=white!60!gray,colframe=white!20!gray]
On Considère une va $X$ à valeurs dans $\{1,2,3\}$ et de loi: $P\left(X=1\right)=\dfrac{1}{6}$, $P\left(X=2\right)=\dfrac{1}{3}$ $P\left(X=3\right)=\dfrac{1}{2}$.

Calculer $E\left(X\right)$ et $E\left(X^{3}\right)$ 
\end{tcolorbox}
\tcblower
On a : $E\left(X \right)=\sum_{k=1}^{3}kP\left(X=k\right)=1\dfrac{1}{6}+2\dfrac{1}{3}+3\dfrac{1}{2}=\dfrac{7}{3}$.
D'après la formule de transfert : 
\[E\left(X^3\right)=\sum_{k=1}^{3}P\left(X=k \right)=1^{3}\dfrac{1}{6}+2^{3}\dfrac{1}{3}+3^{3}\dfrac{1}{2}=\dfrac{49}{3} \]
\end{Box1}

\begin{Box2}[sidebyside align=top seam]{Méthode}
\begin{tcolorbox}[colback=white,colframe=white!20!gray,width=.8\linewidth]
Pour calculer la variance $V\left( X\right)$ d'une va $X$
\end{tcolorbox}
\tcblower
Essayer de :
\noindent 
\begin{itemize}
\item Utiliser la formule : $V\left( X\right)=E\biggl(\left(X-E(x)\right)^{2}\biggr) $
\item Utiliser la formule : $V\left( X\right)=E\left( X^2\right)-\left(E\left( X^2\right)\right)^{2} $
\item Utiliser la formule : $V\left( X\right)=a^{2}V\left(Y\right)$ si $X=aY+b$
\end{itemize}
\mbox{}\hfill  Exercice $28.1$ à $28.5$
\end{Box2}

\end{document}

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.