0

I want to format a table in my beamer presentation. The code for the whole frame of the presentation is the following:

\begin{frame}
\frametitle{Results}
\hspace{-29mm}
\vspace{-29mm}
 \begin{center}
 \begin{table}[h]
   \caption{Error during the evalution}
    \label{tab:3} \centering
     \begin{tabular}{| c | c | c | c | c |c | c | c | c |}
     \hline
      \textbf{Subject}  & \textbf{k=3} & \textbf{k=5} & \textbf{k=7} & 
     \textbf{k=9} & \textbf{k=11} & \textbf{k=13} & \textbf{k=15} \\ \hline
    \textbf{Gramnar}& 4.708 & 3.454 & 2.489 & 2.223 & 2.380 & 2.615 & 2.622  \\ \hline
  \end{tabular}
\end{table}
\end{center}
\end{frame}

What I want is to control the space between the left border of the presentation with my table. It seems that the table is really close to the left border of the whole presentation while in the right side there is a big space. How can I balance the white space between the both sides?

0

3 Answers 3

2

Not really made for this, but a column might help:

\documentclass{beamer}

\begin{document}
    \begin{frame}
        \frametitle{Results}
        \begin{columns}
            \begin{column}{\paperwidth}
                \begin{table}
                    \centering
                \caption{Error during the evalution}
                \label{tab:3} \centering
                \begin{tabular}{| *{9}{c |} }
                    \hline
                    \textbf{Subject}  & \textbf{k=3} & \textbf{k=5} & \textbf{k=7} &
                    \textbf{k=9} & \textbf{k=11} & \textbf{k=13} & \textbf{k=15} \\ \hline
                    \textbf{Gramnar}& 4.708 & 3.454 & 2.489 & 2.223 & 2.380 & 2.615 & 2.622  \\ \hline
                \end{tabular}
                \end{table}
            \end{column}
        \end{columns}
    \end{frame}
\end{document}

enter image description here

1
  • good trick! (+1)
    – Zarko
    Commented Apr 11, 2017 at 21:48
3

There is no need for \hspace{-29mm}, \vspace{-29mm}, \begin{center}, or the [h] specifier for table. Also, the table is a bit wider than the textwidth, so adding \small can fix this without sacrificing readability.

\begin{frame}
\frametitle{Results}
\begin{table}
  \small\centering
   \caption{Error during the evalution}
    \label{tab:3} 
     \begin{tabular}{|*9{c|}}
     \hline
      \textbf{Subject}  & \textbf{k=3} & \textbf{k=5} & \textbf{k=7} & 
     \textbf{k=9} & \textbf{k=11} & \textbf{k=13} & \textbf{k=15} \\ \hline
    \textbf{Grammar}& 4.708 & 3.454 & 2.489 & 2.223 & 2.380 & 2.615 & 2.622  \\ \hline
  \end{tabular}
\end{table}
\end{frame}

enter image description here

3

Your table is slightly to wide to be fit in frame text width. Consequently it spill out (if you delete surpluses \hspace{-29mm} and \vspace{-29mm}) to right text border. For this are available two solutions:

  • increase text width
  • reduce width of table.

Example for the first possibility:

\documentclass{beamer}

\usepackage{changepage}
\begin{document}
\begin{frame}
\frametitle{Results}
 \begin{table}
 \begin{adjustwidth}{-2em}{-2em}% for local increasing text width
 \centering
   \caption{Error during the evalution}
    \label{tab:3} \centering
     \begin{tabular}{| *{9}{c |} }
     \hline
      \textbf{Subject}  & \textbf{k=3} & \textbf{k=5} & \textbf{k=7} &
     \textbf{k=9} & \textbf{k=11} & \textbf{k=13} & \textbf{k=15} \\ \hline
    \textbf{Gramnar}& 4.708 & 3.454 & 2.489 & 2.223 & 2.380 & 2.615 & 2.622  \\ \hline
  \end{tabular}
\end{adjustwidth}
\end{table}
\end{frame}
\end{document}

enter image description here

Example for the second possibility:

\documentclass{beamer}

\begin{document}
\begin{frame}
\frametitle{Results}
 \begin{table}
 \centering
 \setlength\tabcolsep{4pt}
   \caption{Error during the evalution}
    \label{tab:3} \centering
     \begin{tabular}{| *{9}{c |} }
     \hline
      \textbf{Subject}  & \textbf{k=3} & \textbf{k=5} & \textbf{k=7} &
     \textbf{k=9} & \textbf{k=11} & \textbf{k=13} & \textbf{k=15} \\ \hline
    \textbf{Gramnar}& 4.708 & 3.454 & 2.489 & 2.223 & 2.380 & 2.615 & 2.622  \\ \hline
  \end{tabular}
\end{table}
\end{frame}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .