# Fit table in beamer

I am using the rescale option that was suggested in the other posts in this forum to fit a table in beamer. However, the contents of the table move out of the frame.

\documentclass{beamer}
\usepackage{graphicx}
\begin{document}
\scalebox{0.7}{
\begin{table}[h!]
\centering
\caption{ }
\begin{tabular}{|c|c|c|c|c|c| }
\hline
Name & Name&Name&NameName&NameName\\
\hline
NameName&-&-&-&-\\
NameName&NameName B &NameName B &- &NameName B\\
NameName&NameName A&NameName A&NameName A&NameName A\\
NameName&NameName B &NameName &-&- \\
NameName&NameName C&NameName C&NameName C&-\\
NameName&-&NameName&-&-\\
NameName&-&NameName&-&\\
\hline
\end{tabular}
\end{table}
}
\end{document}


Could someone help me to identify what's wrong in syntax that I am using?

Some suggestions:

• Don't forget to employ frame environments in a beamer document.

• In a beamer document, table and figure environments don't float.

• Get rid of begin{table} and \end{table}, and place the caption text in the frame title.

• There's not much to say about the tabular environment. I suggest you use a \resizebox directive to make it fit inside the width of the text block.

• No need to load the graphicx package explicitly: In the beamer document class, this package is loaded automatically.

Here, then, is how I would rewrite your code:

\documentclass{beamer}
\begin{document}
\begin{frame}{Tissue-specific expression of isoenzymes of
NameNamelase for seven different species}
\resizebox{\textwidth}{!}{%
\begin{tabular}{|c|c|c|c|c|c|}
\hline
Name & Name&Name&NameName&NameName\\
\hline
NameName&-&-&-&-\\
NameName&NameName B &NameName B &- &NameName B\\
NameName&NameName A&NameName A&NameName A&NameName A\\
NameName&NameName B &NameName &-&- \\
NameName&NameName C&NameName C&NameName C&-\\
NameName&-&NameName&-&-\\
NameName&-&NameName&-&\\
\hline
\end{tabular}
} % end of scope of "\resizebox"  directive
\end{frame}
\end{document}

• I would like to know whether it is possible to highlight the first column and first row in a different color – Natasha May 4 '18 at 11:02
• @Natasha - The short answer to your follow-up queston is, "yes". However, not knowing which color, or colors, you have in mind, I can't give a specific longer answer. All I can suggest for now is that you familiarize yourself with the colortbl package and its \rowcolor and \columncolor macros. – Mico May 4 '18 at 11:31