我想tikzpicture
用此代码绘制我的矩阵 U=[matrix]
\begin{align*}
U&=
\begin{tikzpicture}[decoration=brace]
\matrix (m)[matrix of math nodes,left delimiter=[,right delimiter={]},ampersand replacement=\&] {
\dfrac{2}{N}-1 \& \dfrac{2}{N} \& \cdots \& \dfrac{2}{N} \& \cdots\& \dfrac{2}{N} \\
\vdots \& \vdots \& \ddots \& \cdots \& \vdots \& \vdots \\
\,\,\,\,\,\dfrac{2}{N}\,\,\,\, \& \dfrac{2}{N} \& \dfrac{2}{N} \& \dfrac{2}{N}-1 \& \cdots \& \dfrac{2}{N} \\
\vdots \& \vdots \& \vdots \& \vdots \& \ddots \& \vdots\\
\dfrac{2}{N} \& \dfrac{2}{N} \& \cdots \& \dfrac{2}{N} \& \cdots \& \dfrac{2}{N}-1\\
};
\draw[decorate,transform canvas={xshift=-1.4em},thick] (m-3-1.south west) -- node[left=2pt] {$m$} (m-1-1.north west);
\draw[decorate,transform canvas={yshift=0.5em},thick] (m-1-1.north west) -- node[above=2pt] {$m$} (m-1-4.north east);
\end{tikzpicture}
\end{align*}
但我无法对齐U=
。我该如何做到这一点?
答案1
只需将baseline
选项添加到tikzpicture
;我还做了一些其他修改来改进您的代码(特别是现在括号完全是水平和垂直的):
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,matrix}
\tikzset{
table/.style={
matrix of math nodes,
row sep=-\pgflinewidth,
column sep=-\pgflinewidth,
nodes={rectangle,text width=3em,align=center},
text depth=1.25ex,
text height=2.5ex,
nodes in empty cells,
left delimiter=[,
right delimiter={]},
ampersand replacement=\&
}
}
\begin{document}
\[
U=
\begin{tikzpicture}[baseline,decoration=brace]
\matrix (m) [table] {
\dfrac{2}{N}-1 \& \dfrac{2}{N} \& \cdots \& \dfrac{2}{N} \& \cdots\& \dfrac{2}{N} \\
\vdots \& \vdots \& \ddots \& \cdots \& \vdots \& \vdots \\
\,\,\,\,\,\dfrac{2}{N}\,\,\,\, \& \dfrac{2}{N} \& \dfrac{2}{N} \& \dfrac{2}{N}-1 \& \cdots \& \dfrac{2}{N} \\
\vdots \& \vdots \& \vdots \& \vdots \& \ddots \& \vdots\\
\dfrac{2}{N} \& \dfrac{2}{N} \& \cdots \& \dfrac{2}{N} \& \cdots \& \dfrac{2}{N}-1\\
};
\draw[decorate,transform canvas={xshift=-1.4em},thick] (m-3-1.south west) -- node[left=2pt] {$m$} (m-1-1.north west);
\draw[decorate,transform canvas={yshift=0.5em},thick] (m-1-1.north west) -- node[above=2pt] {$m$} (m-1-4.north east);
\end{tikzpicture}
\]
\end{document}
这是一个不使用 TikZ 的可能性,使用blkarray
和bigdelim
:
\documentclass{article}
\usepackage{amsmath}
\usepackage{multirow,bigdelim,blkarray}
\newcommand\overmat[3][0pt]{%
\makebox[0pt][l]{$\smash{\overbrace{\phantom{%
\begin{matrix}\phantom{\rule{0pt}{#1}}#3\end{matrix}}}^{#2}}$}#3}
\begin{document}
\[
U =
\begin{blockarray}{@{}r[cccccc]}
\\[-1ex]
\ldelim\{{4}{14pt}[$m$]
& \overmat[27pt]{\textstyle m}{\dfrac{2}{N}-1 & \dfrac{2}{N} & \cdots & \dfrac{2}{N}\qquad} & \cdots& \dfrac{2}{N}
\\ & \vdots & \vdots & \ddots & \cdots & \vdots & \vdots
\\ & \,\,\,\,\,\dfrac{2}{N}\,\,\,\, & \dfrac{2}{N} & \dfrac{2}{N} & \dfrac{2}{N}-1 & \cdots & \dfrac{2}{N}
\\ & \vdots & \vdots & \vdots & \vdots & \ddots & \vdots
\\ & \dfrac{2}{N} & \dfrac{2}{N} & \cdots & \dfrac{2}{N} & \cdots & \dfrac{2}{N}-1
\\[2ex]
\end{blockarray}
\]
\end{document}