如何在 LaTex 中绘制带阴影边框的文本框

如何在 LaTex 中绘制带阴影边框的文本框

如何在 LaTex 中绘制带阴影边框的文本框?我尝试了以下方法,但出现错误:

\fbox{
\begin{minipage}[c]{5in}
   \shadowbox{\large\bf text write here}
\end{minipage}
}

答案1

主要问题是:盒子应该是什么样子?可以使用tikzmdframedtcolorbox等绘制无限变化的盒子。

以下是一些建议tcolorbox

在此处输入图片描述

\documentclass{article}
\usepackage[skins]{tcolorbox}
\begin{document}

\tcbox[enhanced,size=fbox,fontupper=\large\bfseries,drop shadow southwest,
    sharp corners]{(A) text write here}

\begin{tcolorbox}[enhanced,width=5in,center upper,size=fbox,
    fontupper=\large\bfseries,drop shadow southwest,sharp corners]
(B) text write here
\end{tcolorbox}

\tcbox[enhanced,fontupper=\large\bfseries,drop shadow southwest,
    sharp corners]{(C) text write here}

\begin{tcolorbox}[enhanced,width=5in,center upper,
    fontupper=\large\bfseries,drop shadow southwest,sharp corners]
(D) text write here
\end{tcolorbox}

\tcbox[enhanced,fontupper=\large\bfseries,drop fuzzy shadow southwest,
    colframe=red!50!black,colback=yellow!10]{(E) text write here}

\begin{tcolorbox}[enhanced,width=5in,center upper,
    fontupper=\large\bfseries,drop fuzzy shadow southwest,
    colframe=red!50!black,colback=yellow!10]
(F) text write here
\end{tcolorbox}

\tcbox[enhanced,fontupper=\large\bfseries,drop fuzzy shadow southwest,
    boxrule=0.4pt,sharp corners,colframe=yellow!80!black,
    colback=yellow!10]{(G) text write here}

\begin{tcolorbox}[enhanced,width=5in,center upper,
    fontupper=\large\bfseries,drop fuzzy shadow southwest,
    boxrule=0.4pt,sharp corners,colframe=yellow!80!black,colback=yellow!10]
(H) text write here
\end{tcolorbox}

\end{document}

答案2

tikz

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadows}
\begin{document}
  \begin{tikzpicture}
    \node [copy shadow={fill=blue,shadow xshift=-0.5ex,shadow yshift=-0.5ex},
            fill=blue!20,draw=blue,thick,font=\bfseries] {text write here};
  \end{tikzpicture}

\end{document}

在此处输入图片描述

这是高度可定制的,如下所示:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadows}
\begin{document}
  \begin{tikzpicture}
    \node [copy shadow={draw=red,fill=red,opacity=0.5,shadow xshift=-0.5ex,
           shadow yshift=-0.5ex},fill=blue!20,draw=blue,thick,font=\bfseries]
            {text write here};
  \end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容