Is there an easy way to have node border anchors centered on the borders?

The simplest thing to do is specify outer sep=0:

Sample output

\documentclass{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[ultra thick, MyNode/.style={draw, minimum height=1cm}]
  \draw[step=1cm,gray,ultra thin] (-1cm,-3cm) grid (5cm,2cm);

  % default case
  \begin{scope}[red]
    \path (0,0) node[MyNode, anchor=south west, minimum
    width=1cm,outer sep=0] (n1) {};
    \path (n1.east) ++(1cm,0) node[MyNode, anchor=west, minimum
    width=2cm,outer sep=0] {};
  \end{scope}

  \begin{scope}[blue, shift={(0,-2)}]
    \path (0,0) ++(-0.5\pgflinewidth,-0.5\pgflinewidth)
      node[MyNode, anchor=south west, minimum width=1cm] (n1) {};
    \path (n1.east) ++(1cm,0) ++(-\pgflinewidth,0)
      node[MyNode, anchor=west, minimum width=2cm] {};
  \end{scope}

\end{tikzpicture}

\end{document}

However, if connecting these nodes by lines or arrows, you will need to shorten them to avoid overlapping the borders.


A probably much more useless approach than Andrew's would be to draw the node with no line width and decorate it with a fat border.

Change one line:

\begin{tikzpicture}[MyNode/.style={draw, minimum height=1cm, line width=0pt, postaction={ultra thick, draw}}]

Tags:

Nodes

Tikz Pgf