# Place matrix and graph side-by-side

I am trying to place a matrix and a graph side-by-side in a tabular format, using the following code:

\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}


This is correct, but I would like to put the symbol $\implies$ between the matrix and the graph. How can I do that? It is my first question here, so I am sorry for layout error.

• Welcome to TeX.SX! It would be better to surround the example with code for being compilable with LaTeX, but it's not a big deal here. – egreg Jan 9 '18 at 16:34
• One solution is to change the column specification to p{5cm}@{$\implies$}c which would result in the symbol between the two columns. I did not test vertical alignment though. – Skillmon Jan 9 '18 at 16:39
• Don't use \begin{center} in a figure environment. This adds unwanted space. Instead use \centering. – Skillmon Jan 9 '18 at 16:40
• Also, in a math environment I'd use \mathbf not \textbf. – Skillmon Jan 9 '18 at 16:42
• Thanks for your help. If I use p{5cm}@{$\implies$}c, I get this error: Missing p-arg in array arg. \begin{tabular}p – Mik Jan 9 '18 at 16:43

No need for the tabular, place the tikzpicure inside the math. You just need baseline=(2.base) in the optional argument of the tikzpicture to get the proper vertical alignment.

\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}