TransWikia.com

Changing the font size in a table

TeX - LaTeX Asked by csgillespie on May 25, 2021

What’s the recommend way of changing the font size in a particular table? Is there a better way than enclosing all values with, for example, the tiny function.

3 Answers

Scale down your table to the textwidth

documentclass{article}
usepackage{graphicx}
begin{document}

begin{table}
resizebox{textwidth}{!}{%
  begin{tabular}{cc}
    Knuth & Lamport
  end{tabular}}
end{table}

end{document}

then you have the optimal font size. However, all tabular lines are also scaled down which doesn't matter because it looks nicer.

Correct answer by user2478 on May 25, 2021

Write tiny immediately after begin{table}. If you don't use a (floating) table environment, enclose your (e.g.) tabular environment in a group and write tiny after begingroup.

documentclass{article}

begin{document}

begin{table}
tiny
centering
begin{tabular}{cc}
Knuth & Lamport
end{tabular}
end{table}

end{document}

EDIT: To change the fontsize for all tables (or even floats of every type), one may use the floatrow package (this also saves typing centering in every table):

documentclass{article}

usepackage{floatrow}
DeclareFloatFont{tiny}{tiny}% "scriptsize" is defined by floatrow, "tiny" not
floatsetup[table]{font=tiny}

begin{document}

begin{table}
begin{tabular}{cc}
Knuth & Lamport
end{tabular}
end{table}

end{document}

Answered by lockstep on May 25, 2021

An easier way to change the font size for ALL tables:

usepackage{etoolbox}

AtBeginEnvironment{tabular}{tiny}

Answered by DianChao Lin on May 25, 2021

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