[Tex/LaTex] matrix and figure side by side

floatsmatricesminipage

I would like to put a matrix next to a figure in my text. Currently the display is as can be seen in the image. I prefer the matrix on the left and the tree on the right.
enter image description here

I am using this:

\usepackage{amsmath}
\usepackage{graphicx}
\includegraphics[scale=.8]{Graficos/arbolR1.pdf} 
\caption{R-vine from Matrix M. Tree 1.}
\label{fig:R-vine1}

\begin{figure}
\centering
\small
\label{M}
\(
M= 
\begin{pmatrix}
5&&&&&&&&\\
8&1&&&&&&&\\
2&8&2&&&&&&\\
3&2&8&3&&&&&\\
4&3&7&8&4&&&&\\
9&4&9&7&8&8&&&\\
7&9&3&9&7&9&7&&\\
6&7&4&4&9&7&9&6&\\
1&6&6&6&6&6&6&9&9\\
\end{pmatrix}
\)
\caption{Matrix Structure}
\end{figure}

I will appreciate any help!!!!

Best Answer

Please see the following MWE (I used minipage for this):

\documentclass{article}

\usepackage{amsmath}
\usepackage{graphicx}

\begin{document}

\begin{figure}
\centering
\begin{minipage}[b]{.45\textwidth}
\includegraphics[width=\textwidth]{example-image-a}
\caption{First caption}\label{first}
\end{minipage}\hfill
\begin{minipage}[b]{.45\textwidth}
%\begin{figure}
\centering
\small
\label{M}
\(
M= 
\begin{pmatrix}
5&&&&&&&&\\
8&1&&&&&&&\\
2&8&2&&&&&&\\
3&2&8&3&&&&&\\
4&3&7&8&4&&&&\\
9&4&9&7&8&8&&&\\
7&9&3&9&7&9&7&&\\
6&7&4&4&9&7&9&6&\\
1&6&6&6&6&6&6&9&9\\
\end{pmatrix}
\)
\caption{Matrix Structure}\label{second}
%\end{figure}
\end{minipage}
\end{figure}

\end{document}

with the result:

resulting pdf

Related Question