[Tex/LaTex] Correctly wrap a tikz figure next to a tabular

tablestikz-pgf

I'm trying to find a way to correctly put a table next to a tabular, I found this but changing the value of the first textwidth I don't get the result wanted. I would like to have the two objects centered as they are an unique object, but as you can see in the image they are more near to the right side. I think my error is with the minipage environment, but cannot understand how to solve.

enter image description here

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{geometry}
\geometry{a4paper,top=2cm,bottom=3cm,left=2.5cm,right=3cm,% per regolare i bordi a piacimento
heightrounded,bindingoffset=5mm}
\usepackage{amsmath} % per poter usare le lettere calligrafiche
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{graphicx} % per inserire immagini
\usepackage{tikz}
\usepackage{wrapfig} % per scrivere di fianco alle immagini
\usepackage{gensymb}

\begin{document}

\begin{table}[h]
\begin{minipage}{0.4\textwidth}
\centering
\begin{tikzpicture}
\draw [->] (0,0) -- (3,0);
\draw [->] (0,0) -- (0,2.2);
\draw (2,0) arc [start angle=0,end angle=90,radius=2cm];
\draw (0,0) -- (2.6,2) node [above] {T};
\draw (-0.2,2) node [above] {S} -- (3,2) node [right] {$t$};
\draw (0.5,0) arc [start angle=0,end angle=37,radius=0.5cm];
\draw (-0.2,-0.2) node {O};
\draw (0.7,0.2) node {$\alpha$};
\draw [dashed] (1.58,1.21) node [right] {P}-- (0,1.21) node [left] {R};
\draw (2.6,0) node [below] {$x_T$};
\draw [red,thick] (0,0) -- (2.6,0);
\draw [dashed] (2.6,2) -- (2.6,0);
\end{tikzpicture}
\end{minipage}
%\begin{minipage}{0.2\textwidth}
\centering
\begin{tabular}{l|lllllll}
$\alpha$ & 0\degree & 30\degree & 45\degree & 60\degree & 90\degree & 180\degree & 270\degree\\
\hline
$\tan\alpha$ & 0 & $\frac{\sqrt{3}}{3}$ & 1 & $\sqrt{3}$ & $\nexists$ & 0 & $\nexists$\\
\hline
$\cot\alpha$ & $\nexists$ & $\sqrt{3}$ & 1 & $\frac{\sqrt{3}}{3}$ & 0 & $\nexists$ & 0
\end{tabular}
%\end{minipage}
\end{table}

\end{document}

Best Answer

Remove the minipage altogether, set the baseline for the tikzpicture, and use a single \centering, added before \begin{tikzpicture}. You can increase the space between diagram and table with \hspace{<length>}. Increasing \arraystretch might improve the table a bit, giving some extra space between the fractions and the \hlines.

(The frame in the image is due to the showframe option for geometry.)

output of code

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{geometry}
\geometry{
  showframe, % to show the extent of the text area etc.
  a4paper,top=2cm,bottom=3cm,left=2.5cm,right=3cm,% per regolare i bordi a piacimento
heightrounded,bindingoffset=5mm}
\usepackage{amssymb}
\usepackage{mathtools} % loads amsmath
\usepackage{tikz} % loads graphicx
\usepackage{gensymb}

\begin{document}

\begin{table}[h]
\renewcommand\arraystretch{1.5}
\centering
\begin{tikzpicture}[baseline=(current bounding box.center)]
\draw [->] (0,0) -- (3,0);
\draw [->] (0,0) -- (0,2.2);
\draw (2,0) arc [start angle=0,end angle=90,radius=2cm];
\draw (0,0) -- (2.6,2) node [above] {T};
\draw (-0.2,2) node [above] {S} -- (3,2) node [right] {$t$};
\draw (0.5,0) arc [start angle=0,end angle=37,radius=0.5cm];
\draw (-0.2,-0.2) node {O};
\draw (0.7,0.2) node {$\alpha$};
\draw [dashed] (1.58,1.21) node [right] {P}-- (0,1.21) node [left] {R};
\draw (2.6,0) node [below] {$x_T$};
\draw [red,thick] (0,0) -- (2.6,0);
\draw [dashed] (2.6,2) -- (2.6,0);
\end{tikzpicture}\hspace{5mm}
\begin{tabular}{l|lllllll}
$\alpha$ & 0\degree & 30\degree & 45\degree & 60\degree & 90\degree & 180\degree & 270\degree\\
\hline
$\tan\alpha$ & 0 & $\frac{\sqrt{3}}{3}$ & 1 & $\sqrt{3}$ & $\nexists$ & 0 & $\nexists$\\
\hline
$\cot\alpha$ & $\nexists$ & $\sqrt{3}$ & 1 & $\frac{\sqrt{3}}{3}$ & 0 & $\nexists$ & 0
\end{tabular}
\end{table}
\end{document}