我有以下文本框:
\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}