
Quiero formatear una tabla en mi presentación de proyector. El código para todo el frame de la presentación es el siguiente:
\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}
Lo que quiero es controlar el espacio entre el borde izquierdo de la presentación con mi mesa. Parece que la mesa está muy cerca del borde izquierdo de toda la presentación mientras que en el lado derecho hay un gran espacio. ¿Cómo puedo equilibrar el espacio en blanco entre ambos lados?
Respuesta1
Realmente no está hecho para esto, pero una columna podría ayudar:
\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}
Respuesta2
No es necesario \hspace{-29mm}
, \vspace{-29mm}
, \begin{center}
ni el [h]
especificador de table
. Además, la tabla es un poco más ancha que el ancho del texto, por lo que agregarla \small
puede solucionar este problema sin sacrificar la legibilidad.
\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}
Respuesta3
Su tabla es un poco demasiado ancha para caber en el ancho del texto del marco. En consecuencia, se derrama (si elimina los excedentes \hspace{-29mm}
y \vspace{-29mm}
) hasta el borde derecho del texto. Para ello están disponibles dos soluciones:
- aumentar el ancho del texto
- reducir el ancho de la mesa.
Ejemplo de la primera posibilidad:
\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}
Ejemplo de la segunda posibilidad:
\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}