1

This question already has an answer here:

I have the following example:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}

    \begin{equation}
     \begin{tikzpicture}[baseline=(current bounding box.center)]
        \matrix (m) [matrix of math nodes,nodes in empty cells,
        nodes=draw,
        right delimiter={]},
        left delimiter={[}, 
        row sep=0.1cm, 
        column sep=0.1cm,
        minimum width=1.5cm,
        minimum height=1.5cm]
      {
       \mathbf{M}_0 & \mathbf{0} &        &     &        & \mathbf{0} & A(0)(0) & A(0)(1)  & \mathbf{0}   &        &        & \mathbf{0}   \\
       \mathbf{0} & \mathbf{M}_0 &        &     &        &        & \mathbf{0}  & -A(0)(0) & A(0)(1)  &        &        &          \\
              &        & \mathbf{M}_0 &     &        &        &         &          & -A(0)(0) &        &        &          \\
              &        &        &     &        &        &         &          &          &        &        & \mathbf{0}   \\
              &        &        &     &        & \mathbf{0} &         &          &          &        &        & A(0)(1)  \\
      \mathbf{0}  &        &        &     & \mathbf{0} & M(0) & \mathbf{0}  &          &          &        & \mathbf{0} & -A(0)(0) \\
      \mathbf{M}_0 & \mathbf{0} &        &     &        & \mathbf{0} & A(0)(0) & A(0)(1)  & \mathbf{0}   &        &        & \mathbf{0} \\
       \mathbf{0} & \mathbf{M}_0 &        &     &        & \mathbf{0} & \mathbf{0}  & -A(0)(0) & A(0)(1)  & \mathbf{0} &        & \mathbf{0} \\
              & \mathbf{0} & \mathbf{M}_0 &     &        & \mathbf{0} &         & \mathbf{0}   & -A(0)(0) &        &        & \mathbf{0}  \\
              &        &        &     &        &        &         &          & \mathbf{0}   &        &        & \mathbf{0} \\
              &        &        &     &        & \mathbf{0} &         &          &          &        &        & A(0)(1) \\
      \mathbf{0}  & \mathbf{0} & \mathbf{0} &     & \mathbf{0} & M(0) & \mathbf{0}  & \mathbf{0}   & \mathbf{0}   &        & \mathbf{0} & -A(0)(0) \\
      } ;


    \end{tikzpicture}
   \end{equation}
\end{document}

How can I align all the nodes, some boxes (empty) are somehow out of alignment?

Thanks alot!

marked as duplicate by Ignasi, Guido, Claudio Fiandrino, T. Verron, clemens Jun 26 '13 at 10:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    empty nodes have their anchor in center while non empty nodes have it in their baseline. Change nodes=draw with nodes={draw,anchor=center} and all nodes will be center aligned. – Ignasi Jun 25 '13 at 10:53