TransWikia.com

Table doesn't fit in the beamer

TeX - LaTeX Asked by SDP on December 8, 2020

Question: Table doesn’t appear entirely in the frame of my beamer document. Please guide me

documentclass[12pt,fleqn]{beamer}
usepackage{booktabs}
begin{document}
begin{frame}
frametitle{A large table}

resizebox{textwidth}{!}{%
    begin{tabular}{*{5}{c}}
        toprule
        $x$ & $y$ & $x^2$ & $y^2$ & $xy$ 
        midrule
        43 & 29 & 1849 & 841 & 1247 
        44 & 31 & 1936 & 961 & 1364 
        46 & 19 & 2116 & 361 & 874 
        40 & 18 & 1600 & 324 & 720 
        44 & 19 & 1936 & 361 & 836 
        42 & 27 & 1764 & 729 & 1134 
        45 & 27 & 2025 & 729 & 1215 
        42 & 29 & 1764 & 841 & 1218 
        38 & 41 & 1444 & 1681 & 1558 
        40 & 30 & 1600 & 900 & 1200 
        42 & 26 & 1764 & 676 & 1092 
        57 & 10 & 3249 & 100 & 570
        bottomrule
    end{tabular}%
}
end{frame}
end{document}​

One Answer

Never use resizebox with tables – it leads to inconsistent font sizes, and sometimes unreadable tables.

Use an environment that lets you specify the overall table width, such as tabular* or tabularx. You also can play with the standard font sizes (small, &c.) and the value of tabcolsep.

In this case, I propose the following code, using `tabular*:

documentclass[12pt,fleqn]{beamer}
usepackage{booktabs}

begin{document}
begin{frame}
frametitle{A large table}

centeringbegin{tabular*}{framewidth}{@{extracolsep{fill}}*{5}{c}}
        toprule
        $x$ & $y$ & $x^2$ & $y^2$ & $xy$ 
        midrule
        43 & 29 & 1849 & 841 & 1247 
        44 & 31 & 1936 & 961 & 1364 
        46 & 19 & 2116 & 361 & 874 
        40 & 18 & 1600 & 324 & 720 
        44 & 19 & 1936 & 361 & 836 
        42 & 27 & 1764 & 729 & 1134 
        45 & 27 & 2025 & 729 & 1215 
        42 & 29 & 1764 & 841 & 1218 
        38 & 41 & 1444 & 1681 & 1558 
        40 & 30 & 1600 & 900 & 1200 
        42 & 26 & 1764 & 676 & 1092 
        57 & 10 & 3249 & 100 & 570
        bottomrule
    end{tabular*}
end{frame}

end{document}​ 

enter image description here

Correct answer by Bernard on December 8, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP