5

I have several tables of each one with 3 columns. The first and the third columns are the same size for all tables, but the second column is different.

Because the length the line in the second line is different, some tables have small fonts and the second column is wider than other tables.

I would like to have the same with for the second column in all tables and same font size.

This is the way I made all tables:

\begin{table}[]
\centering
\caption{tile X}
\resizebox{.8\textwidth}{!}{
\label{my-label}
\begin{tabular}{|l|l|l|}
\hline
term ID    & description                & log10 p-value \\ \hline
GO:0000502 & proteasome complex         & -1.5144       \\ \hline
GO:0005575 & cellular\_component        & -0.9977       \\ \hline
GO:0005739 & mitochondrion              & -1.1136       \\ \hline
GO:0034515 & proteasome storage granule & -1.3222       \\ \hline
\end{tabular}}
\end{table}
2
  • Should the widths of the first and third columns also match across tables? Are all entries in the first column of the same format as GO:0000502, and are all entries in the third column numbers with a minus sign, one digit before the decimal point, and exactly four digits after the decimal point?
    – Mico
    Aug 10, 2015 at 17:36
  • Yes, first and third column hace the same format across all tables and in all cases the length of characters is the same. Aug 10, 2015 at 17:49

1 Answer 1

3

If you want all tables to have the same font size while still occupying the same width (of 0.8\textwidth), don't use the \resizebox approach. Instead, load the tabularx package, specify the width of each tabularx environment to be 0.8\textwidth, and use X (or a suitably modified version of X) as the type for the second column. (By "suitably modified", I mean a version of X that typesets its material ragged-right while still allowing hyphenation.)

You may also want to consider dropping all vertical lines from the tabular (or tabularx) environments, dropping most \hline directives and replacing the few remaining instances of \hline with \toprule, \midrule, and \bottomrule (three macros provided by the booktabs package), respectively. Compare the looks of the two tables below: Which one would you say has a more "open" look and thus invites the reader to linger and actually "read" the table's contents?

enter image description here

\documentclass{article}
\usepackage{siunitx,tabularx,ragged2e,booktabs,caption}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash}X}
\newcolumntype{T}[1]{S[table-format=#1]}
\begin{document}

\begin{table}
\centering
\caption{tile X} \label{my-label-X}
\begin{tabularx}{0.8\textwidth}{|l|Y|T{-1.4}|}
\hline
term ID    & description         & {log10 p-value} \\ \hline
GO:0000502 & proteasome complex  & -1.5144         \\ \hline
GO:0005575 & cellular\_component & -0.9977         \\ \hline
GO:0005739 & mitochondrion       & -1.1136         \\ \hline
GO:0034515 & proteasome storage granule & -1.3222  \\ \hline
\end{tabularx}
\end{table}

\begin{table}[h!]
\centering
\caption{tile XX} \label{my-label-XX}
\begin{tabularx}{0.8\textwidth}{@{}lYT{-1.4}@{}}
\toprule
term ID    & description         & {log10 p-value} \\ \midrule
GO:0000502 & proteasome complex  & -1.5144       \\ 
GO:0005575 & cellular\_component & -0.9977       \\ 
GO:0005739 & mitochondrion       & -1.1136       \\ 
GO:0034515 & proteasome storage granule & -1.3222 \\ 
\bottomrule
\end{tabularx}
\end{table}

\end{document} 
9
  • Simply loading the caption package would make the vertical skip between caption and table more sensible.
    – Bernard
    Aug 10, 2015 at 18:07
  • @Bernard - Thanks for this suggestion. I've incorporated it in the example.
    – Mico
    Aug 10, 2015 at 18:17
  • h! is not a float placement one normally should use.
    – MaxNoe
    Aug 10, 2015 at 20:46
  • @MaxNoe - In my view, one shouldn't normally insist on having each and every float appear right where it's encountered in the input file...
    – Mico
    Aug 10, 2015 at 21:14
  • Indeed. So why taking possibilities away from latex by not giving the t, b and p placements?
    – MaxNoe
    Aug 10, 2015 at 21:17

You must log in to answer this question.

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