如何定制阴影盒?

如何定制阴影盒?

我有以下文本框:

\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}

在此处输入图片描述

我该怎么做才能将其自定义为下图这样:

在此处输入图片描述

答案1

没有shadowbox解决方案(承认),但我建议使用这个tcolorbox方案和它的一系列极端选项

\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}

在此处输入图片描述

相关内容