10

I want to fit the following table on a beamer slide.

\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}
A & B & C & D & E & F & G & H & I & J & K & L & M & N & O & P & Q & R & S & T & U & V & W &   X & Y & Z \\
G & T & U & J & C & P & L & D & O & R & Y & W & X & Z & F & I & V & Q & S & K & A & N & E & M & H & B \\
\end{tabular}

However it won't fit, because there is too much space in a single column. If the borders were to perfectly enclose the letters, it would fit.

Does anyone know how to do that?

4
  • 5
    You can use @{}c@{} instead of c to remove the cell spacing. Also try to set \tabcolsep to 0pt. Dec 14, 2011 at 14:28
  • 2
    have you considered to redefine \tabcolsep, the separation between columns. Also you could delete it completely with {@{}c@{}...}. A smaller font would probably be better. Maybe using tabularx you can squeeze it to textwidth. A working example would be good. Some beamer themes have a side bar and some don't...
    – Martin H
    Dec 14, 2011 at 14:29
  • 3
    @MartinScharrer's suggestion should work just fine for you. Note that you can use the * notation to make things a little easier on you. You won't have to change 26 occurences. Just go |@{}c@{}*{25}{|@{}c@{}}|. Dec 14, 2011 at 14:35
  • 1
    The @{}c@{} method works! The result fits, but a little bit of spacing would be ok. Is there a way to do a little bit of spacing and keep the *-notation?
    – Ben Ruijl
    Dec 14, 2011 at 15:49

2 Answers 2

12

Modify the length \tabcolsep to compress the table horizontally.

\documentclass[smaller]{beamer}
\usepackage[T1]{fontenc}
\usepackage{fix-cm}

\setlength{\tabcolsep}{2pt}

\begin{document}
  \begin{frame}
    \begin{tabular}{|*{26}{c|}}
      A & B & C & D & E & F & G & H & I & J & K & L & M & N & O & P & Q & R & S & T & U & V & W &   X & Y & Z \\
      G & T & U & J & C & P & L & D & O & R & Y & W & X & Z & F & I & V & Q & S & K & A & N & E & M & H & B \\
    \end{tabular}
  \end{frame}
\end{document}
3
  • How can I, if I even can, use this hint with tabular* environment? I've tried structure \begin{tabular*}{\textwidth}{cccc} and table was narrower than text width but \hlines were exceeding the table (they have full width).
    – Crowley
    Feb 1, 2012 at 11:00
  • @Crowley a tabular* or tabularx have to have a stretchable column, you are not giving it any, so the environment is confused :-)
    – yo'
    Jul 14, 2017 at 20:29
  • Is it possible to reset the value of \tabsolsep afterwards? Jun 22, 2023 at 18:29
3
\documentclass{beamer}
\begin{document}
  \begin{frame}
  \resizebox{\linewidth} {\height}{%
    \setlength\tabcolsep{2pt}%
    \begin{tabular}{|*{26}{c|}}
      A & B & C & D & E & F & G & H & I & J & K & L & M & N & O & P & Q & R & S & T & U & V & W &   X & Y & Z \\
      G & T & U & J & C & P & L & D & O & R & Y & W & X & Z & F & I & V & Q & S & K & A & N & E & M & H & B \\
    \end{tabular}}
  \end{frame}
\end{document}

You must log in to answer this question.

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