I want to make a matrix with TikZ so I can put some fancy colored boxes around some elements, but I'm running into a problem: the parentheses around the matrix are too big and too far apart from the elements, at least compared to the regular \pmatrix
. Here's an example:
\documentclass{article}
\usepackage{amsmath,tikz}
\usetikzlibrary{matrix}
\begin{document}
AMSMath:
\[ \begin{pmatrix}
1 & 2 & 3 \\
4 & 5 & 6
\end{pmatrix} \]
TikZ:
\[ \begin{tikzpicture}
\matrix[matrix of math nodes,left delimiter=(,right delimiter=)] (m) {
1 & 2 & 3 \\
4 & 5 & 6 \\ }; \end{tikzpicture} \]
TikZ without delimiters + AMSMath:
\[ \begin{pmatrix} \begin{tikzpicture}
\matrix[matrix of math nodes] (m) {
1 & 2 & 3 \\
4 & 5 & 6 \\ }; \end{tikzpicture} \end{pmatrix} \]
\end{document}
If I don't use TikZ delimiters and put everything inside a \pmatrix
, like in the third example, the parentheses look slightly different but they're still too big. The same thing happens with brackets. Is there a way around this?
Best Answer
The delimiters can be shifted through the styles
every (left|right) delimiter
: