12

Could someone make this picture in sample code in LaTeX and please make it in different style with different colors. enter image description here

Here is my attempt:

\fbox{
  \parbox{\linewidth}{
     This example will show you how we can ..
     $dX_{t}=b(t,X_{t})+\sigma (t,X_{t}) dW_{t}$
     \begin{center}
       \begin{tabular}{ l | c || r } \hline
         W & S  \\ \hline
         + & -  \\ \hline
       \end{tabular}
     \end{center}
   }
}
9

Here's the start of something that will create what you're looking for:

\documentclass{article}
\usepackage{xcolor}
\usepackage{fancybox}
\pagestyle{empty}
\begin{document}

\noindent
\shadowbox{%
\begin{minipage}{\dimexpr\textwidth-\shadowsize-2\fboxrule-2\fboxsep}
   \textcolor{red}{\sffamily EXAMPLE 3.}\par\vspace{\baselineskip}

    \hspace*{\fill}
    %--------------------------%
    \setlength{\shadowsize}{2pt}
    \parbox{2in}{\shadowbox{$\displaystyle  dX_t = - \frac{1}{2X_t}I(X_t\not=)dt+dW_t$}}
    %--------------------------%
    \hspace*{\fill}
    %--------------------------%
    {\sffamily
    \begin{tabular}{|c|c|}\hline
     \textcolor{red}{W} & \textcolor{blue}{S} \\\hline
     $-$                & $-$                 \\\hline
    \end{tabular}}
    %-------------------------%
    \hspace*{\fill}\par\vspace{1ex}

\end{minipage}}

\end{document}

enter image description here

UPDATE

If you want to color the box, I would recommend you look at the examples using mdframed given by @GonzaloMedina --- I'm not all that familiar with this package. You might also consider looking at the package tcolorbox (also illustrated by GonzaloMedina), but it also seems to rely on the tikz bundle of packages and libraries.

  • Thaks so much work great but with (underfull \hbox badness 10000) – Educ Jul 10 '13 at 0:58
  • 1
    Hmmm. Not quite sure where that's coming from. I'll look at that. – A.Ellett Jul 10 '13 at 1:59
  • 1
    Fixed. It was the use of `\\`. You shouldn't get the underfull box errors now. – A.Ellett Jul 10 '13 at 2:06
  • Thanks Mr A.Ellett but still give me this time just one bad box error (overfull \hbox in paragraph at line334-335 ( \parbox{2in}{\shadowbox{$\displaystyle dX_t =-\frac{1}{2X_t}I(X_t\not=0)dt+dW_t$}} ) – Educ Jul 10 '13 at 14:53
  • I fixed by change 2in to 3in Thanks my best to all of you – Educ Jul 10 '13 at 15:03
12

One option using the features provided by tcolorbox:

\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage[most]{tcolorbox}
\usetikzlibrary{shadows}

\newcounter{exa}

\tcbset{
myexample/.style={
  enhanced,
  colback=yellow!10!white,
  colframe=red!50!black,
  fonttitle=\scshape,
  titlerule=0pt,
  title={\refstepcounter{exa}example~\theexa.},
  title style={fill=yellow!10!white},
  coltitle=red!50!black,
  drop shadow,
  highlight math style={reset,colback=LightBlue!50!white,colframe=Navy}
  }
}

\newtcolorbox{texample}{myexample}

\begin{document}

\begin{texample}
\centering
\tcbhighmath{\textrm{d}X_{t}=b(t,X_{t})+\sigma (t,X_{t}) \textrm{d}W_{t}}\quad
\begin{tabular}{|c|c|}
\hline
\textcolor{red!70!black}{W} & \textcolor{Navy}{C} \\
\hline
$+$ & $-$ \\
\hline
\end{tabular}
\end{texample}

\end{document}

enter image description here

Here's now an option using mdframed and hf-tikz:

\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage[framemethod=tikz]{mdframed}
\usepackage[customcolors]{hf-tikz}
\usetikzlibrary{shadows}

\newcounter{exa}

\newmdenv[
settings={\refstepcounter{exa}},
linewidth=1pt,
innertopmargin=1.5\baselineskip,
roundcorner=6pt,
backgroundcolor=yellow!10,
linecolor=red!70!black,
frametitle=example~\theexa,
frametitlefont=\scshape\color{red!70!black},
shadow=true
]{mdexample}

\begin{document}

\begin{mdexample}
\centering
\hfsetfillcolor{LightBlue!50}
\hfsetbordercolor{Navy}
\tikzmarkin{a}(0.3,0.6)(-0.3,-0.4)$\textrm{d}X_{t}=b(t,X_{t})+\sigma (t,X_{t}) \textrm{d}W_{t}$\tikzmarkend{a}\qquad
\begin{tabular}{|c|c|}
\hline
\textcolor{red!70!black}{W} & \textcolor{Navy}{C} \\
\hline
$+$ & $-$ \\
\hline
\end{tabular}
\end{mdexample}

 \end{document}

enter image description here

  • Thanks so much for ur code but gives error in package pgfkeys error:I do not know the key '/tcb/rest' and i am going to ignore it .prehpas you misspelled it – Educ Jul 10 '13 at 0:53
  • @Educ it's not "rest"; it is "reset".In any case, you need the most recent version of tcolorbox package: version 2.33 (2013/07/04). – Gonzalo Medina Jul 10 '13 at 0:55
  • 1
    @Educ here's the link on CTAN. MiKTeX has a package manager that can download it for you (unfortunately, I don't use MiKTeX, so I cannot tell you the exact instructions for the package manager, but here is some useful link). – Gonzalo Medina Jul 10 '13 at 1:07
  • 2
    @Educ besides installing you have to refresh the File Data Base (again, I don't know the details since I don't use MiKTeX). In any case, remove reset and that should solve the problem. Or also, see my updated answer for another option with mdframed and hf-tikz. – Gonzalo Medina Jul 10 '13 at 1:26
  • 1
    @Educ MikTeX got an update yesterday (maybe in the night) which includes the recent tcolorbox. I do not know if this update was available a few hours agp, so, please, try again to update MikTeX. This time it should work :-) – Thomas F. Sturm Jul 10 '13 at 6:13

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.