7

How do I draw a text box with shadow borders in LaTex? I have tried the following but it has errors:

\fbox{
\begin{minipage}[c]{5in}
   \shadowbox{\large\bf text write here}
\end{minipage}
}
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Jan 18 '15 at 10:29
  • Which error does TeX spill out? Did you use \usepackage{fancybox} ? And do you really nead a frame around \shadowbox? – user31729 Jan 18 '15 at 10:30
  • i m not using \usepackage{fancybox}, i m new to latex and i want to draw a simple text-box having a shadow border at its left side. i m not understanding how to code this in latex. – sadaf Jan 18 '15 at 10:39
  • Try to use my provided answer as a starting point. And change \bf to \textbf{...} since \bf is deprecated syntax – user31729 Jan 18 '15 at 10:43
  • Other packages: mdframed or tcolorbox – user31729 Jan 18 '15 at 10:48
6

The main question is: How should the box look like? The box can be drawn with unlimited variations using tikz, mdframed, tcolorbox, etc.

Here are some suggestions with tcolorbox:

enter image description here

\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}
  • Is there an easy way to use these boxes with a paragraph? – Glen Wheeler Jun 24 '16 at 6:19
  • @GlenWheeler Inside the tcolorbox examples, you could use paragraphs, but not inside the tcbox examples. – Thomas F. Sturm Jun 24 '16 at 7:38
3

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

enter image description here

This is highly customizable as can be seen below:

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

enter image description here

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.