11

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?

14

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

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.