TransWikia.com

Align font size for tables with different number of columns

TeX - LaTeX Asked by nohomejerome on March 6, 2021

I am fairly new to LaTeX and I have a quite basic question. I create tables like this:

begin{table}[H]
    resizebox{textwidth}{!}{%
        begin{tabular}{@{extracolsep{5pt}}lD{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} }
            Test & 1 & 2 & 3
end{tabular}}
end{table} 

However, I have a lot of tables and their number of columns differs. Accordingly, the font size changes automatically to my marginal settings (resizebox{textwidth}), i.e. the more columns the table has the smaller the font size. Is there a way to align the font size of all tables at once?

I know that I can decrease the font size manually by increasing the number within extracolsep{5pt} to e.g.

extracolsep{10pt}

However, I don’t want to do this for every table and compare the results until they roughly coincide.

Thanks!

One Answer

Never scale tables, as you see, scaling just produces inconsistent font sizes.

Simply use

begin{table}[htbp]
     small
        begin{tabular}{lD{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} }
            Test & 1 & 2 & 3
end{tabular}
end{table}

or if small is still too large footnotsize.

Note that extracolsep does nothing in tabular (it is used to give stretch space for tabular* to achieve the target width of the table). I also removed [H] which should be used very sparingly as it disables the float positioning algorithm (and specifying that the table may float is the sole purpose of the table environment).

Answered by David Carlisle on March 6, 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