[Tex/LaTex] Fill and draw option

tikz-pgf

Is there a single option to set both the draw and the fill color of a TikZ node?

Something like:

\node[rectangle,drawandfill=red]{test};

The actual problem is the following: I have many adiacent rectangles node with different filling colors. Each rectangle has a different filling color.

Now I need to remove the tiny white border around each rectangle and I want that each rectangle has a drawing color equal to its filling color.

Since it would be a pain to rewrite draw=<color name> for every rectangle, I was hoping for a command like fillanddrawn=<color name> so that I could use some search and replace feature to add all the drawing colors at once.

Best Answer

You can define your own parameterized style to do this, with

\tikzset{drawandfill/.style={draw=#1,fill=#1}}

Complete example:

\documentclass[tikz]{standalone}
\begin{document}
\tikzset{drawandfill/.style={draw=#1,fill=#1}}
\begin{tikzpicture}
  \node[rectangle,drawandfill=red] at (0,0) {test};
  \node[rectangle,fill=red,draw=red] at (1,0) {test};
\end{tikzpicture}
\end{document}

The two nodes are identical:

enter image description here