# Drawing a rectangular shape with a border around it in TikZ

Could anyone please tell me how do I draw a rectangular shape with a black border around it?

I want that for all my rectangles in the following TikZ picture:

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[every node/.style = {shape          = rectangle,
rounded corners,
fill           = black!30!white,
minimum width  = 3cm,
minimum height = 1.5cm,
align          = center,
text           = black},
black edge/.style  = { -,
ultra thick,
black,
shorten >= 2pt}]

\node(0;0) at (5,0) {Patients};
\node(1;1)  at (10, 2) {Treatment $A_1$};
\node(1;-1) at (10,-2) {Treatment $A_2$};
\foreach \j in {-1,1}
{ \draw[black edge] (0;0.east) -- (1;\j.west); }
\end{tikzpicture}
\end{document}

• Add draw= black in the every node style. – jub0bs Mar 29 '13 at 14:49
• The question is wrong. You want to draw a border with a node and with a rectangle's shape. It's not exactly a rectangle like with (a,b) rectangle (c,d) – Alain Matthes Mar 29 '13 at 16:17
• Is draw (or draw=black) what you needed and wanted? Or do you actually want to draw two lines as in the answers below? draw just draws the border of a shape (here: a rectangular with rounded corners) and works for every node shape. Or do you want to draw a rectangle wit the path operator somewhere around the nodes? – Qrrbrbirlbel Mar 30 '13 at 3:59

You can use draw,double=<color>,double distance = <dimen> in every node style.:

\documentclass{article}

\setlength{\parindent}{0mm}

\usepackage{paralist}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[every node/.style = {shape          = rectangle,
rounded corners,
draw,                    %% here
double=red,              %% here
double distance =1pt,    %% here
fill           = black!30!white,
minimum width  = 3cm,
minimum height = 1.5cm,
align          = center,
text           = black},
black edge/.style  = { -,
ultra thick,
black,
shorten >= 2pt}]

\node(0;0) at (5,0) {Patients};
\node(1;1)  at (10, 2) {Treatment $A_1$};
\node(1;-1) at (10,-2) {Treatment $A_2$};
\foreach \j in {-1,1}
{ \draw[black edge] (0;0.east) -- (1;\j.west); }
\end{tikzpicture}

\end{document}


If you don't want color, use simple double instead of double=<color>.

With PSTricks.

\documentclass[pstricks,border=12pt]{standalone}
\newpsobject{myrec}{psframe}
{
border=2\pslinewidth,
bordercolor=black,
}

\begin{document}
\begin{pspicture}[showgrid](4,3)
\myrec[linecolor=yellow](2,1.5)
\myrec[linecolor=white](2.5,2)(4,3)
\end{pspicture}
\end{document}

• Border-lining on –1: a) PSTricks, b) rectangles in arbitrary/random places and c) not related to any of the elements resulting from OP’s code. – Qrrbrbirlbel Mar 30 '13 at 3:57