1

I am trying to include a table of data in a document. I have an underfull warning and the text looks too small to me. How do I make the text bigger?

Ideally I want the table to have the same font size as the rest of the document and the numbers to be right justified. At the moment the text is so small the righthand end of the column titles are vertically aligned with the left hand size of the numbers.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{adjustbox}
\usepackage{makecell}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{tabularx}
\usepackage{geometry}
    \geometry{a4paper, total={160mm,247mm}, left=25mm,top=25mm, }

\begin{document}

% \begin{center} \begin{adjustbox}{max width=16cm} \begin{tabular}{|m{2cm}|m{2cm}|m{3cm}|m{3cm}|m{3cm}|m{3cm}|} \hline Velocity (m/s) & Reynolds number & Viscous X \par force & Viscous Y \par force & Viscous X \par force & Viscous Y \par force \ \hline \hfill 1 & \hfill 2 & \hfill 1247.208 & \hfill 0.401 & \hfill 1935.377 & \hfill 0.071 \ \hline \hfill 10 & \hfill 20 & \hfill 12487.550 & \hfill 40.039 & \hfill 19370.400 & \hfill 7.136 \ \hline \hfill 100 & \hfill 200 & \hfill 136167.000 & \hfill 3472.528 & \hfill 206349.900 & \hfill 714.765 \ \hline \end{tabular} \end{adjustbox} %\end{center}

\end{document}

Ingmar
  • 6,690
  • 5
  • 26
  • 47
Ross
  • 21
  • 1
    Hi, Welcome! Hmm... if it doesn't fit, it doesn't fit --- you are explicitly asking to resize it, which you should never do with tables. Suggestion: put the titles in the first row in two rows, use maybe \small. There are hundreds of question about tables that does not fit here... – Rmano Jul 13 '22 at 09:33

3 Answers3

2

The problem is that you are scaling the table.

Don't specify cell widths and let TeX compute them. You can get a better rendering if you split the long texts across rows. And much better alignment with siunitx features.

\documentclass{article}
\usepackage{geometry}
\usepackage{booktabs,siunitx}

\geometry{a4paper, total={160mm,247mm}, left=25mm,top=25mm}

\begin{document}

\begin{center} % local settings \newcommand{\splitcell}[1]{\smash{\begin{tabular}[t]{@{}c@{}}#1\end{tabular}}} \sisetup{group-minimum-digits=3}

\begin{tabular}{ @{} S[table-format=3.0] S[table-format=3.0] S[table-format=6.3] S[table-format=4.3] S[table-format=6.3] S[table-format=3.3] @{} } \toprule {\splitcell{Velocity \ (\unit{m/s})}} & {\splitcell{Reynolds \ number}} & \multicolumn{4}{c}{Force} \ \cmidrule{3-6} && {Viscous X} & {Viscous Y} & {Viscous X} & {Viscous Y} \ \midrule 1 & 2 & 1247.208 & 0.401 & 1935.377 & 0.071 \ 10 & 20 & 12487.550 & 40.039 & 19370.400 & 7.136 \ 100 & 200 & 136167.000 & 3472.528 & 206349.900 & 714.765 \ \bottomrule \end{tabular} \end{center}

\end{document}

enter image description here

egreg
  • 1,121,712
1

Why not using tabularxinstead of tabular̀?

\begin{adjustbox}{max width=16cm}
  \begin{tabularx}{16cm}{|*6{X|}}
  \hline
  Velocity (m/s) & Reynolds number & Viscous X \par force  & Viscous Y \par force  & Viscous X \par force  & Viscous Y \par force \\ 
  \hline
  \hfill 1 & \hfill 2 & \hfill 1247.208 & \hfill 0.401 & \hfill 1935.377 & \hfill 0.071 \\ 
  \hline
  \hfill 10 & \hfill 20 & \hfill 12487.550 & \hfill 40.039 & \hfill 19370.400 & \hfill 7.136 \\ 
  \hline
  \hfill 100 & \hfill 200 & \hfill 136167.000 & \hfill 3472.528 & \hfill 206349.900 & \hfill 714.765 \\ 
  \hline

\end{tabularx} \end{adjustbox}

tabularx

gigiair
  • 1,812
0
  • Similarly as @egreg answer (+1¸), but with use of the tabularray package version 2022B:
  • Don't scale tables! Rather design narrower table columns so.
  • For aligning numbers (at decimal points) use `siunitx} package

Edit: Specification numbers format is changed from default to format of numbers in columns.

\documentclass{article}
\usepackage[a4paper,
            total={160mm,247mm}, left=25mm,top=25mm]{geometry}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\usepackage{tabularray} \UseTblrLibrary{booktabs, siunitx}

\begin{document} \begin{center} \sisetup{group-minimum-digits=3} \begin{tblr}{colspec = {*{2}{Q[c, si={table-format=3.0}]} Q[c, si={table-format=6.3}] Q[c, si={table-format=4.3}] Q[c, si={table-format=6.3}] Q[c, si={table-format=3.3}]}, row{1,2}= {guard} } \toprule \SetCell[r=2]{c} {Velocity\ (m/s)} & \SetCell[r=2]{c} {Reynolds\ number} & \SetCell[c=4]{c} Force & & & \ \midrule & & Viscous X & Viscous Y & Viscous X & Viscous Y \ \midrule 1 & 2 & 1247.208 & 0.401 & 1935.377 & 0.071 \ 10 & 20 & 12487.550 & 40.039 & 19370.400 & 7.136 \ 100 & 200 & 136167.000 & 3472.528 & 206349.900 & 714.765 \ \bottomrule \end{tblr} \end{center} \end{document}

enter image description here

(red lines indicate text area borders)

Zarko
  • 296,517