# How to have a cross out rectangle in tikz?

I have the following tikz style

  \tikzset{actor/.style={ rectangle, minimum size=6mm, very thick,
draw=red!50!black!50, top color=white, bottom
color=red!50!black!20 }
}


and I would like to have an other style which is the same but with a cross out in the rectangle. How can I achieve this ?

-
Instead of posting code snippets, it's usually preferred to post a complete minimal example document. That saves others the work of having to come up with a test document themselves. –  Jake Sep 19 '12 at 9:20

You can use append after command in conjunction with the fit library to place a cross out node (which comes from the shapes.misc library) over the actor node:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes.misc, fit}

\begin{document}
\begin{tikzpicture}
\tikzset{
actor/.style={
rectangle, minimum size=6mm, very thick,
draw=red!50!black!50, top color=white, bottom
color=red!50!black!20
},
actor crossed out/.style={
actor,
append after command={
node [
fit=(\tikzlastnode),
draw=red!50!black!50,
thick,
inner sep=-\pgflinewidth,
cross out
] {}
}
}
}

\node [actor] (a) {A};
\node [actor crossed out, right of = a] {B};

\end{tikzpicture}
\end{document}


Alternatively, you can use edges in the append after command to draw the lines. This does not require any libraries:

\documentclass{article}

\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\tikzset{
actor/.style={
rectangle, minimum size=6mm, very thick,
draw=red!50!black!50, top color=white, bottom
color=red!50!black!20
},
actor crossed out/.style={
actor,
append after command={
[every edge/.append style={
thick,
red!50!black!50,
shorten >=\pgflinewidth,
shorten <=\pgflinewidth,
}]
(\tikzlastnode.north west) edge (\tikzlastnode.south east)
(\tikzlastnode.north east) edge (\tikzlastnode.south west)
}
}
}

\node [actor] (a) {A};
\node [actor crossed out, right of = a] {B};

\end{tikzpicture}
\end{document}

-