tikz 矩陣分佈不均勻

tikz 矩陣分佈不均勻

怎樣才能使盒子分佈均勻?程式碼如下:

\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}

現在輸出看起來很難看: 在此輸入影像描述

答案1

添加anchor=center到您的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}

輸出:

矩陣

相關內容