(Note: I've edited this question quite a bit because it turned out my original problem was caused by two separate issues, so I'm separating them into two questions. The other question is Changing inner sep of tikz matrix without affecting the nodes inside it )
Consider the following MWE
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix} % for "matrix of math nodes"
\begin{document}
\begin{equation}
\left[
\begin{tikzpicture}[baseline=(current bounding box.center)]
\matrix[matrix of math nodes] {
a & b & c\
d & e & f \
};
\end{tikzpicture}
\right]
\end{equation}
\end{document}
It produces this output:
This isn't very satisfactory, because of the uneven spacing around the matrix.
Changing the matrix command to \matrix[matrix of math nodes, draw] { ... }; gives this result:
So I think the issue is about the baseline not being where it needs to be in order for the brackets to line up correctly. But I don't know where the baseline should be, so I'm unsure what to do to fix the problem.



remember pictureactive, and then drew the connections afterwards, but that sort of thing turned out to be slow.) – N. Virgo Aug 11 '22 at 03:05nicematrixpackage? It might be powerful enough to support what you are trying to achieve overall and also might have fixes for things like this already. – Andrew Stacey Aug 11 '22 at 07:31