How to adjust the alignment of this 10x10 matrix?

You can use these set of options instead.

nodes={
    anchor=center,
    outer sep=0,
    inner sep=0pt,
    text width=1cm,
    align=center,
    minimum size=1cm -\pgflinewidth
    }

enter image description here


For this particular case, I think it's easier to draw all nodes and not using the background grid.

When option matrix of nodes is used, nodes change the anchor to base, so if you want a vertically centered alignment, anchor=center has to be included in nodes= definition.

\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{matrix}

\begin{document}

\begin{tikzpicture} 
%\draw[step=1cm,color=white!80!black] (0,0) grid (10,10);
\matrix[matrix of nodes,
        inner sep=0pt,
        anchor=south west,
        row sep=-\pgflinewidth,
        column sep=-\pgflinewidth,
        nodes={draw=black!30,
                anchor=center,
                align=center,
                minimum size=1cm,
                outer sep=0pt,
             }
        ]{
%           0   1   2   3   4   5   6   7   8   9 
            A & . & . & . & . & . & . & . & . & . \\
            B & C & D & . & . & . & . & . & . & . \\
            . & F & E & . & . & . & . & . & . & . \\
            H & G & . & . & . & . & . & . & . & . \\
            I & . & . & . & . & . & . & . & . & . \\
            J & . & . & . & . & . & . & . & Z & . \\
            K & . & . & R & S & T & U & V & Y & . \\
            L & M & P & Q & . & . & . & W & X & . \\
            . & N & O & . & . & . & . & . & . & . \\
            . & . & . & . & . & . & . & . & . & . \\
        };
\end{tikzpicture}   
\end{document}

enter image description here

Tags:

Tikz Pgf