[Tex/LaTex] Rotating text at the side of a table

rotatingtables

In the following code I want to rotate the text 'Probability' 90 degrees and have it in a column to itself at the left hand side of the table. I would also like vertical bars either side of the top row 'Probability'. As you can see, I haven't been able to achieve this, here is my code –

\begin{document}
\begin{figure}[h]
\centering
    \scalebox{0.7}{
    $\begin{tabular}{|c | c | c | c | c | c | c | c | c | c | c | c |}
    \hline
    \multicolumn{12}{c}{Position}  \\ \hline
     & -5 & -4 & -3 & -2 & -1 & 0 & 1 & 2 & 3 & 4 & 5  \\ \hline
     & 0          & 0         & 0         & 0         & 0         & 1     & 0         & 0         & 0         & 0         & 0         \\ \hline
     & 0          & 0         & 0         & 0         & 0.5       & 0     & 0.5       & 0         & 0         & 0         & 0         \\ \hline
     & 0          & 0         & 0         & 0.25      & 0         & 0.5   & 0         & 0.25      & 0         & 0         & 0         \\ \hline
     & 0          & 0         & 0.125     & 0         & 0.375     & 0     & 0.375     & 0         & 0.125     & 0         & 0         \\ \hline
     & 0          & 0.0625    & 0         & 0.25      & 0         & 0.375 & 0         & 0.25      & 0         & 0.0625    & 0         \\ \hline
     & 0.03125    & 0         & 0.15625   & 0         & 0.3125    & 0     & 0.3125    & 0         & 0.15625   & 0         & 0.03125   \\ \hline
     \rot{\rlap{~Probability}} \\
    \end{tabular}$
    }
\caption{Probabilities for the first $5$ steps of a classical random walk.}
\label{cw_first_5_steps}
\end{figure}
\end{document}

Edit: This doesn't work either!

\begin{figure}[h]
\centering
    \scalebox{0.8}{
    $\begin{tabular}{|c | c | c | c | c | c | c | c | c | c | c | c |}
    \hline
    \multicolumn{12}{c}{Position}  \\ \hline
     & -5           & -4        & -3        & -2        & -1        & 0     & 1         & 2         & 3         & 4         & 5         \\ \hline
     \multirow{6}{*}{\rotatebox[origin=c]{90}{Probability}}&
     & 0            & 0         & 0         & 0         & 0         & 1     & 0         & 0         & 0         & 0         & 0         \\ \hline
     & 0            & 0         & 0         & 0         & 0.5       & 0     & 0.5       & 0         & 0         & 0         & 0         \\ \hline
     & 0            & 0         & 0         & 0.25      & 0         & 0.5   & 0         & 0.25      & 0         & 0         & 0         \\ \hline
     & 0            & 0         & 0.125     & 0         & 0.625     & 0     & 0.125     & 0         & 0.125     & 0         & 0         \\ \hline
     & 0            & 0.0625    & 0         & 0.625     & 0         & 0.125 & 0         & 0.125     & 0         & 0.0625    & 0         \\ \hline
     & 0.03125      & 0         & 0.53125   & 0         & 0.125     & 0     & 0.125     & 0         & 0.15625   & 0         & 0.03125   \\ \hline
    \end{tabular}$
    }
\caption{Probabilities for the first $5$ steps of a classical random walk.}
\label{cw_first_5_steps}
\end{figure}

Best Answer

Is something like this what you seek? I used \cline to avoid the horizontal lines in column 1, I used {|c|} in the multicolumn to get vertical lines on row 1, and I placed the rotated text as an element in column one of one of the rows itself.

\documentclass{article}
\usepackage{graphicx}
\def\rot#1{\rotatebox{90}{#1}}
\begin{document}
\begin{figure}[h]
\centering
    \scalebox{0.7}{
    $\begin{tabular}{|c | c | c | c | c | c | c | c | c | c | c | c |}
    \hline
    \multicolumn{12}{|c|}{Position}  \\ \hline
     & -5 & -4 & -3 & -2 & -1 & 0 & 1 & 2 & 3 & 4 & 5  \\ \cline{2-12}
     & 0          & 0         & 0         & 0         & 0         & 1     & 0         & 0         & 0         & 0         & 0         \\ \cline{2-12}
     & 0          & 0         & 0         & 0         & 0.5       & 0     & 0.5       & 0         & 0         & 0         & 0         \\ \cline{2-12}
     & 0          & 0         & 0         & 0.25      & 0         & 0.5   & 0         & 0.25      & 0         & 0         & 0         \\ \cline{2-12}
     & 0          & 0         & 0.125     & 0         & 0.375     & 0     & 0.375     & 0         & 0.125     & 0         & 0         \\ \cline{2-12}
  \rot{\rlap{~Probability}}     & 0          & 0.0625    & 0         & 0.25      & 0         & 0.375 & 0         & 0.25      & 0         & 0.0625    & 0         \\\cline{2-12}
   & 0.03125    & 0         & 0.15625   & 0         & 0.3125    & 0     & 0.3125    & 0         & 0.15625   & 0         & 0.03125   \\ \hline
    \end{tabular}$
    }
\caption{Probabilities for the first $5$ steps of a classical random walk.}
\label{cw_first_5_steps}
\end{figure}
\end{document}

enter image description here