# Table and graph do not align

The table and graph are not vertically aligned and I don't know how to fix it. Any suggestions?

\begin{tabular}{|c|c|} \hline
$x$     &   $y$ \\ \hline
$-2$    &   $-5$    \\ \hline
$-1$    &   $-3$    \\ \hline
$0$ &   $-1$    \\ \hline
$1$ &   $1$ \\ \hline
$2$ &   $3$ \\ \hline
$3$ &   $5$ \\ \hline
\end{tabular}
\hspace{5cm}
\begin{tikzpicture}[scale=.3]
\begin{scope}
\clip (-10,-20) rectangle (10,0);
\draw[step=2cm,gray,very thin]
(-12,-22) grid (10,0);
\end{scope}
\draw [<->] (-11,-10) -- (11,-10);
\draw [<->](0,-21) -- (0,1);
\clip (-10,-20) rectangle (10,0);
\end{tikzpicture}

-

You can use the t option for tabular and (current bounding box.base) for baseline= in the tikzpicture:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tabular}[t]{|c|c|} \hline
$x$     &   $y$ \\ \hline
$-2$    &   $-5$    \\ \hline
$-1$    &   $-3$    \\ \hline
$0$ &   $-1$    \\ \hline
$1$ &   $1$ \\ \hline
$2$ &   $3$ \\ \hline
$3$ &   $5$ \\ \hline
\end{tabular}%
\hspace{5cm}%
\begin{tikzpicture}[baseline=(current bounding box.base),scale=.3]
\begin{scope}
\clip (-10,-20) rectangle (10,0);
\draw[step=2cm,gray,very thin]
(-12,-22) grid (10,0);
\end{scope}
\draw [<->] (-11,-10) -- (11,-10);
\draw [<->](0,-21) -- (0,1);
\clip (-10,-20) rectangle (10,0);
\end{tikzpicture}

\end{document}


Notice the character % that I added twice to remove spurious blank spaces. Perhaps instead of a hardwired horizontal space you could use \hfill.

-
Thank you so much...this is perfect. –  Garth Fleming Aug 26 '12 at 5:14