4

I have the following text box:

\documentclass{article}
\usepackage{xcolor}
\usepackage{fancybox}

\definecolor{ShadowColor}{RGB}{30,150,190}

\makeatletter
\newcommand\Cshadowbox{\VerbBox\@Cshadowbox}
\def\@Cshadowbox#1{%
  \setbox\@fancybox\hbox{\fbox{#1}}%
  \leavevmode\vbox{%
    \offinterlineskip
    \dimen@=\shadowsize
    \advance\dimen@ .5\fboxrule
    \hbox{\copy\@fancybox\kern.5\fboxrule\lower\shadowsize\hbox{%
      \color{ShadowColor}\vrule \@height\ht\@fancybox \@depth\dp\@fancybox \@width\dimen@}}%
    \vskip\dimexpr-\dimen@+0.5\fboxrule\relax
    \moveright\shadowsize\vbox{%
      \color{ShadowColor}\hrule \@width\wd\@fancybox \@height\dimen@}}}
\makeatother

\begin{document}

\colorlet{ShadowColor}{gray}

\Cshadowbox{String1 = String2}

\end{document}

enter image description here

How should I do to customize it equal to the following figure:

enter image description here

2
  • 1
    Will all the boxes contain code listings? Oct 10 '15 at 16:09
  • Hello Gonzalo Medina, in fact must enter a String with the text very large identical to the figure with the Boolean operators in bold. Can you help me? Oct 10 '15 at 18:40
4

No shadowbox solution (admitted) but I suggest the tcolorbox package and its extreme bunch of options

\documentclass{article}
\usepackage{xcolor}
\usepackage{fancybox}

\usepackage[most]{tcolorbox}

\definecolor{ShadowColor}{RGB}{30,150,190}

\makeatletter
\newcommand\Cshadowbox{\VerbBox\@Cshadowbox}
\def\@Cshadowbox#1{%
  \setbox\@fancybox\hbox{\fbox{#1}}%
  \leavevmode\vbox{%
    \offinterlineskip
    \dimen@=\shadowsize
    \advance\dimen@ .5\fboxrule
    \hbox{\copy\@fancybox\kern.5\fboxrule\lower\shadowsize\hbox{%
      \color{ShadowColor}\vrule \@height\ht\@fancybox \@depth\dp\@fancybox \@width\dimen@}}%
    \vskip\dimexpr-\dimen@+0.5\fboxrule\relax
    \moveright\shadowsize\vbox{%
      \color{ShadowColor}\hrule \@width\wd\@fancybox \@height\dimen@}}}
\makeatother

\begin{document}



\colorlet{ShadowColor}{gray}

\begin{tcolorbox}[enhanced jigsaw,sharp corners, drop fuzzy shadow=ShadowColor]
String1 = String2
\end{tcolorbox}

And as listing box: 



   \begin{tcblisting}{listing only,enhanced jigsaw,sharp corners, drop fuzzy shadow=ShadowColor}
String1 = String2

\end{tcblisting}


\end{document}

enter image description here

4
  • Hello Christian Hupfer, that's exactly what I needed, but how should I do to remove the gray background of the text box? The rest is perfect. Oct 10 '15 at 17:59
  • 1
    @ricardoramos: You can use the colback=white option (replace the colorname by your favourite one) in the tcolorbox or tcblisting options. (Sorry for the late answer -- I was at the cinema ;-)
    – user31729
    Oct 10 '15 at 21:02
  • Thank​ you so much for your help Christian Hupfer, now it's all working! Oct 10 '15 at 21:04
  • Key point for future readers. Don't bother with the big markup in the preamble. You just require \usepackage{tcolorbox} and the part after the begin document that uses tcolorbox. Other preamble markup is from OP's original failed effort to us fancybox.
    – pauljohn32
    Dec 4 '20 at 2:28

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.