16

I have the following tikz picture.

\documentclass{standalone}

\usepackage{tikz}
\usepackage{xcolor}

\begin{document}

\begin{tikzpicture}[
  arr/.style={->,   blue, very thick},
  lbl/.style={draw, blue, very thick},
  ]
  \draw[fill=red, very thin] (-1,-1) rectangle (1,1);

  \draw[arr] (-2,0) .. controls (-.75,-.25)  and ( -.25,.75) .. (.5,0); % ARROW
  \node[lbl, anchor=north west] at (.5,0) {};                           % RECTANGLE
\end{tikzpicture}

\end{document}

tikz arrow

How can I add a shadow under the blue rectangle?

How can I add a shadow that follows the blue arrow?

sergej
  • 6,461
  • 32
  • 62

2 Answers2

19

To add a shadow to a node, you may use the shadows library and its drop shadow option.

To add a shadow to a path, you may define a shadowed style using transform canvas option.

enter image description here

\documentclass[tikz]{standalone}
\usetikzlibrary{shadows}
\begin{document}
\begin{tikzpicture}
  \tikzset{
    arr/.style={->,blue,very thick},
    lbl/.style={draw,blue,very thick},
    shadowed/.style={preaction={transform canvas={shift={(2pt,-1pt)}},draw=gray,very thick}},
  }
  \draw[fill=yellow,very thin] (-1,-1) rectangle (1,1);
  \draw[arr,shadowed](-2,0) .. controls (-.75,-1) and ( -.25,1) .. (.5,0)
  node[lbl,anchor=north west,fill=yellow,drop shadow] {};
\end{tikzpicture}
\end{document}
Paul Gaborit
  • 70,770
  • 10
  • 176
  • 283
6

You can fake it using a little translated version by (0.02,-0.02). Or you can define some commands to make the set up easier.

\documentclass{standalone}

\usepackage{tikz}
\usepackage{xcolor}

\begin{document}

\begin{tikzpicture}[
  arr/.style={->,   blue, very thick},
  lbl/.style={draw, blue, very thick},
  ]
  \draw[fill=red, very thin] (-1,-1) rectangle (1,1);
  \draw[xshift=.02,yshift=-0.02,black,very thick,->] (-1.98,-.02) .. controls (-.75,-.25)  and ( -.25,.75) .. (.52,-0.02); % ARROW SHADOW
  \draw[arr] (-2,0) .. controls (-.75,-.25)  and ( -.25,.75) .. (.5,0); % ARROW
  \node[lbl, anchor=north west,black] at (.52,-0.02) {}; %RECT SHADOW
  \node[lbl, anchor=north west] at (.5,0) {}             % RECTANGLE

\end{tikzpicture}

\end{document}

enter image description here

Sigur
  • 37,330