# tikz matrix not distributed evenly [duplicate]

How can I make the box distribute evenly? code as below:

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,positioning}
\begin{document}
\begin{tikzpicture}
\def\lw{1pt} %define linewidth here
\tikzset{box/.style={draw,rotate=90,inner sep=0pt,line width=\lw,
minimum width=2.2cm,minimum height=2.2cm,text width=1.6cm}}
\matrix (M1) [matrix of nodes,draw,inner sep=2pt,
row 1/.style={align=right},
row 5/.style={align=left},
row sep=-\lw,column sep=-\lw,
nodes={box},nodes in empty cells]{
& PORCH 1st &  & DOOR & \\
&  &  &  & \\
&  &  &  & \\
&  &  &  & \\
& BSMT & GARAGE & PORCH 2nd & \\};
\end{tikzpicture}
\end{document}


Now the output seems ugly:

## marked as duplicate by Ignasi tikz-pgf StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Feb 11 '16 at 7:42

• Does inner sep=2pt do anything? – cfr Feb 11 '16 at 3:34

Add anchor=center to your box/.style:

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,positioning}
\begin{document}
\begin{tikzpicture}
\def\lw{1pt} %define linewidth here
\tikzset{box/.style={draw,rotate=90,inner sep=0pt,line width=\lw,
minimum width=2.2cm,minimum height=2.2cm,text width=1.6cm,anchor=center}}
\matrix (M1) [matrix of nodes,draw,inner sep=2pt,
row 1/.style={align=right},
row 5/.style={align=left},
row sep=-\lw,column sep=-\lw,
nodes={box},nodes in empty cells]{
& PORCH 1st &  & DOOR & \\
&  &  &  & \\
&  &  &  & \\
&  &  &  & \\
& BSMT & GARAGE & PORCH 2nd & \\};
\end{tikzpicture}
\end{document}


Output:

• Great, it works now. but why the default anchor so "unstable", it should align the same style but my original output is so "random" distribute. – lucky1928 Feb 11 '16 at 4:10
• The manual states on page 227: "When you place a node at some coordinate, the node is centered on this coordinate by default." So it could be a bug. – Benjamin Feb 11 '16 at 5:15
• @Benjamin: It's not a bug, by design matrix of nodes sets anchor=base which is different in empty and non empty nodes. Take a look at tex.stackexchange.com/questions/78964/… – Ignasi Feb 11 '16 at 7:41
• @Ignasi Thanks. I now also found it in the manual. I have missed that this is a duplicate. Should I just keep my answer here or delete it? I could not find a clear answer on Meta. – Benjamin Feb 11 '16 at 16:07
• @Benjamin Your answer is correct and useful for people who arrives here. So, why to delete it? – Ignasi Feb 11 '16 at 16:40