螺柱 车牌回答问题我发现tikz
矩阵定界符的意外行为:如果数学节点的大小由text width=...
和确定text height=...
,则定界符将按预期工作,但是,如果我用替换它们,minimum size=...
则会出现错误!missing } inserted.. <inserted text> }
。测试示例:
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{matrix}
\newcommand\x{\times}
\begin{document}
\begin{tikzpicture}
\matrix [matrix of math nodes,
nodes={rectangle, %draw, very thin,
minimum size=1.2em, text depth=0.25ex,
inner sep=0pt, outer sep=0pt,
left delimiter=(, right delimiter=),
fill opacity=0.5, text opacity=1,
anchor=center},
column sep=-0.5\pgflinewidth,
row sep=-0.5\pgflinewidth,
column 2/.append style = {nodes={fill=cyan!50}},
row 2/.append style = {nodes={fill=cyan!50}},
row 2 column 2/.append style={nodes={fill=cyan}},
]
{
a_1 & \x & a_3 \\
a_4 & \x & a_6 \\
a_7 & \x & a_9 \\
};
\end{tikzpicture}
\end{document}
如果我注释定界符的定义,则示例如下:
我是否遗漏了什么或者做错了什么?
答案1
您应该将其放置left delimiter=(, right delimiter=)
在nodes
选项之外。
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{matrix}
\newcommand\x{\times}
\begin{document}
\begin{tikzpicture}
\matrix [matrix of math nodes,
nodes={rectangle, %draw, very thin,
minimum size=1.2em, text depth=0.25ex,
inner sep=0pt, outer sep=0pt,
fill opacity=0.5, text opacity=1,
anchor=center},
column sep=-0.5\pgflinewidth,
row sep=-0.5\pgflinewidth,
column 2/.append style = {nodes={fill=cyan!50}},
row 2/.append style = {nodes={fill=cyan!50}},
row 2 column 2/.append style={nodes={fill=cyan}},
left delimiter={(}, right delimiter={)}
]
{
a_1 & \x & a_3 \\
a_4 & \x & a_6 \\
a_7 & \x & a_9 \\
};
\end{tikzpicture}
\end{document}