我有一个图形和一个矩阵,我想将它们显示在一行中,如下例所示。如何让图形和矩阵垂直对齐?当前输出的内容如下所示:
我希望矩阵的底部与图形的底部对齐。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\begin{document}
\[
\tikzstyle{every node}=[circle, draw, fill=black,inner sep=1pt]
\begin{tikzpicture}[node distance=1.3cm,baseline=(4.base)]
\node (1) [label=1] {};
\node (2) [right of=1,label=2] {};
\node (3) [below of=1,label=below:3] {};
\node (4) [right of=3,label=below:4] {};
\path[every node/.style={font=\sffamily\small}]
(1) edge node[left] {} (2)
edge node[left] {} (2)
edge node[left] {} (3)
edge node[left] {} (4)
(2) edge node[left] {} (3)
edge node[left] {} (4)
(3) edge node[left] {} (1)
(4) edge node[left] {} (1);
\end{tikzpicture}
\begin{bmatrix}
0 & 1 & 1 & 1\\
1 & 0 & 1 & 1\\
1 & 1 & 0 & 0\\
1 & 1 & 0 & 0
\end{bmatrix}
\]
\end{document}
答案1
我将 应用\vcenter{\hbox{...}}
到tikzpicture
,因为我知道bmatrix
已经位于数学轴的中心。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\begin{document}
\[
\tikzstyle{every node}=[circle, draw, fill=black,inner sep=1pt]
\vcenter{\hbox{\begin{tikzpicture}[node distance=1.3cm,baseline=(4.base)]
\node (1) [label=1] {};
\node (2) [right of=1,label=2] {};
\node (3) [below of=1,label=below:3] {};
\node (4) [right of=3,label=below:4] {};
\path[every node/.style={font=\sffamily\small}]
(1) edge node[left] {} (2)
edge node[left] {} (2)
edge node[left] {} (3)
edge node[left] {} (4)
(2) edge node[left] {} (3)
edge node[left] {} (4)
(3) edge node[left] {} (1)
(4) edge node[left] {} (1);
\end{tikzpicture}}}
\begin{bmatrix}
0 & 1 & 1 & 1\\
1 & 0 & 1 & 1\\
1 & 1 & 0 & 0\\
1 & 1 & 0 & 0
\end{bmatrix}
\]
\end{document}