# Graph and matrix at the same height

I tried to place a matrix and a graph side by side, but I do not know, how to do it. I found something, but it did not work. (I am beginner.) Thank's.

\begin{tikzpicture}
\centering
[shorten >=1pt,->]
\tikzstyle{vertex}=[circle,fill=blue!25,minimum size=12pt,inner sep=2pt]
\node[vertex] (10) at (1,-1)  [shape=circle,draw=black] {1};
\node[vertex] (11) at (3,-1) [shape=circle,draw=black] {2};
\node[vertex] (12) at (2,-2) [shape=circle,draw=black] {3};
\node[vertex] (13) at (1,-3) [shape=circle,draw=black] {4};
\node[vertex] (14) at (3,-3) [shape=circle,draw=black] {5};
\draw (10) edge[-] (11);
\draw (10) edge[-] (12);
\draw (11) edge[-] (12);
\draw (13) edge[-] (14);
\draw (12) edge[-] (13);
\end{tikzpicture}
\vskip -2cm
$\begin{bmatrix} \centering 0&1&1&0&0 \\ 1&0&1&0&0 \\ 1&1&0&1&0 \\ 0&0&1&0&1 \\ 0&0&0&1&0 \\ \end{bmatrix}$
%\end{minipage}
\begin{center}
Obr. 5
\end{center}
~\\

• Hi, welcome. Is the Obr, 5 meant to be placed right below the matrix? Note that the \centering inside the tikzpicture and bmatrix doesn't do anything. – Torbjørn T. May 27 '18 at 19:59
• I did not know it. Thank you. :) – Euler May 27 '18 at 22:02

I would certainly not use a minipage for that.

\documentclass{article}
\usepackage{tikz}
\begin{document}
$\begin{tikzpicture}[shorten >=1pt,->,baseline=(12.base)] \tikzset{vertex/.style={circle,fill=blue!25,minimum size=12pt,inner sep=2pt}} \node[vertex] (10) at (1,-1) [shape=circle,draw=black] {1}; \node[vertex] (11) at (3,-1) [shape=circle,draw=black] {2}; \node[vertex] (12) at (2,-2) [shape=circle,draw=black] {3}; \node[vertex] (13) at (1,-3) [shape=circle,draw=black] {4}; \node[vertex] (14) at (3,-3) [shape=circle,draw=black] {5}; \draw (10) edge[-] (11); \draw (10) edge[-] (12); \draw (11) edge[-] (12); \draw (13) edge[-] (14); \draw (12) edge[-] (13); \end{tikzpicture}\quad \begin{bmatrix} 0&1&1&0&0 \\ 1&0&1&0&0 \\ 1&1&0&1&0 \\ 0&0&1&0&1 \\ 0&0&0&1&0 \\ \end{bmatrix}$
\end{document}


In case Obr. 5 denotes something like figure 5, put the thing in a figure environment.

• @Euler In order to increase the space, simply replace \quad by \qquad, \quad\quad\quad or \hspace*{1cm} or something along those lines. – marmot May 28 '18 at 7:36

A simple solution is to use minipage, in the example below I set up two of them, each

of them using 30% of the width of the page

\usepackage{amsmath}

\begin{document}

\begin{minipage}{0.3\textwidth}

% graph
\begin{tikzpicture}
[shorten >=1pt,->]
\tikzstyle{vertex}=[circle,fill=blue!25,minimum size=12pt,inner sep=2pt]
\node[vertex] (10) at (1,-1)  [shape=circle,draw=black] {1};
\node[vertex] (11) at (3,-1) [shape=circle,draw=black] {2};
\node[vertex] (12) at (2,-2) [shape=circle,draw=black] {3};
\node[vertex] (13) at (1,-3) [shape=circle,draw=black] {4};
\node[vertex] (14) at (3,-3) [shape=circle,draw=black] {5};
\draw (10) edge[-] (11);
\draw (10) edge[-] (12);
\draw (11) edge[-] (12);
\draw (13) edge[-] (14);
\draw (12) edge[-] (13);
\end{tikzpicture}

\end{minipage}
\begin{minipage}{0.3\textwidth}

% matrix
$\begin{bmatrix} \centering 0&1&1&0&0 \\ 1&0&1&0&0 \\ 1&1&0&1&0 \\ 0&0&1&0&1 \\ 0&0&0&1&0 \\ \end{bmatrix}$

\end{minipage}

\end{document}


Another possibility is to make the matrix part of the tikzpicture, by placing it in a \node.

\documentclass[12pt]{article}
\usepackage{tikz, amsmath}
\usetikzlibrary{positioning}
\begin{document}
\begin{center}
\begin{tikzpicture}[
shorten >=1pt,
vertex/.style={circle,draw=black,fill=blue!25,minimum size=12pt,inner sep=2pt}
]
\node[vertex] (10) at (1,-1)  {1};
\node[vertex] (11) at (3,-1)  {2};
\node[vertex] (12) at (2,-2)  {3};
\node[vertex] (13) at (1,-3)  {4};
\node[vertex] (14) at (3,-3)  {5};

% simpler way of drawing the connections
\draw (12) -- (10) -- (11) -- (12) -- (13) -- (14);

\node [
label=below:Obr. 5, % adds Obr. 5 below the matrix
right=of current bounding box.east, % position it relative to everything made so far in the diagram
] {
$\begin{bmatrix} 0&1&1&0&0 \\ 1&0&1&0&0 \\ 1&1&0&1&0 \\ 0&0&1&0&1 \\ 0&0&0&1&0 \\ \end{bmatrix}$};

\end{tikzpicture}
\end{center}
\end{document}