将矩阵和图形并排放置

将矩阵和图形并排放置

我正在尝试使用以下代码以表格格式并排放置矩阵和图形:

\begin{figure}[h]
\begin{center}
    \begin{tabular}{p{5cm}c}\vspace{-3cm}
    {$\displaystyle
    \textbf{A}=
    \begin{pmatrix}
        10 & 2 & 1 & 4 & 0\\
        2 & 10 & 0 & 0 & 2\\
        1 & 0 & 10 & 0 & 0\\
        4 & 0 & 0 & 10 & 1\\
        0 & 2 & 0 & 1 & 10
    \end{pmatrix}
    $}
    &
    \begin{tikzpicture}
        [auto=left,every node/.style={circle, draw=black, thick, minimum size=0.5cm}]
        \node (0) at (0,1.5) {0};
        \node (1) at (1.5,3) {1};
        \node (2) at (1.5,1.5) {2};
        \node (3) at (1.5,0) {3};
        \node (4) at (3,1.5) {4};
        \draw[-] (0) to (1);
        \draw[-] (0) to (2);
        \draw[-] (0) to (3);
        \draw[-] (1) to (4);
        \draw[-] (3) to (4);
    \end{tikzpicture}
    \end{tabular}
\caption{Caption}
\label{ex}
\end{center}
\end{figure}

这是正确的,但我想在矩阵和图形之间放置符号 $\implies$。我该怎么做?这是我的第一个问题,所以对于布局错误我深表歉意。

答案1

不需要tabular,将放在tikzpicure数学里面。您只需要baseline=(2.base)在的可选参数中tikzpicture获取正确的垂直对齐。

代码输出

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\begin{document}    

\begin{figure}[h]
\centering
$\displaystyle
    \mathbf{A}=
    \begin{pmatrix}
        10 & 2 & 1 & 4 & 0\\
        2 & 10 & 0 & 0 & 2\\
        1 & 0 & 10 & 0 & 0\\
        4 & 0 & 0 & 10 & 1\\
        0 & 2 & 0 & 1 & 10
    \end{pmatrix}
\implies
        \begin{tikzpicture}[baseline=(2.base),auto=left,every node/.style={circle, draw=black, thick, minimum size=0.5cm}]
        \node (0) at (0,1.5) {0};
        \node (1) at (1.5,3) {1};
        \node (2) at (1.5,1.5) {2};
        \node (3) at (1.5,0) {3};
        \node (4) at (3,1.5) {4};
        \draw[-] (0) to (1);
        \draw[-] (0) to (2);
        \draw[-] (0) to (3);
        \draw[-] (1) to (4);
        \draw[-] (3) to (4);
    \end{tikzpicture}
$
\caption{Caption}
\label{ex}
\end{figure}
\end{document}

相关内容