2

This question already has an answer here:

I'm trying to create a matrix of nodes that I will then use as a grid for overlaying my real nodes on top of it, but for some reason the grid appears misaligned once I overlay something on top of it, or put some content inside of the nodes.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{matrix,fit}

\begin{document}

\begin{tikzpicture}
    \matrix (table) [
        matrix of nodes, nodes in empty cells,
        row  sep=1mm, column sep=1mm, inner sep=0mm, outer sep=0mm,
        nodes = { draw, minimum width=10mm, minimum height=10mm } ]
        {
        $Resc_1$ & & & & & & & & \\
        $Resc_2$ & & & & & & & & \\
        };
\end{tikzpicture}

\end{document}

What am I doing wrong? How can I align the first column with the rest of the matrix?

marked as duplicate by Ignasi tikz-pgf Sep 10 '14 at 9:51

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
    Add anchor=center to the nodes options. – percusse Sep 10 '14 at 9:41
  • @Let_Me_Be: I've marked this question as a duplicate if you think I'm wrong, let me know. – Ignasi Sep 10 '14 at 10:00
  • @Ignasi: In my opinion, it is not a duplicate. My suggestion: \documentclass{article} \usepackage{tikz} \usetikzlibrary{matrix} \begin{document} \begin{tikzpicture} \matrix (table) [matrix of nodes, nodes in empty cells, row sep=-\pgflinewidth, column sep=-\pgflinewidth, nodes={draw,minimum width=10mm,minimum height=10mm,anchor=center}] { $Resc_1$ & & & & & & & & \\ $Resc_2$ & & & & & & & & \\ }; \end{tikzpicture} \end{document} – Black Mild Sep 19 at 8:46
  • @BlackMild I think both questions show the same problem, empty and non empty nodes are not equally positioned when matrix of nodes is used. The reason is that matrix of nodes changes anchor=center to anchor=base, therefore we should revert this change in nodes options. Why do you think they are different questions? What does your code propose that is different from percusse's comment? – Ignasi Sep 19 at 10:01
  • @Ignasi row sep and column sep should be changed. – Black Mild Sep 19 at 12:02

Browse other questions tagged or ask your own question.