0

I am having some problems with my table where the entries seem to not be left aligning. I define the table in the following way

\begin{table}[h]
\scriptsize
\caption{Image label frequency}
\label{tab-1}       % Give a unique label
\begin{tabu}to 0.45\textwidth {|X[l]|X[l]|X[l]|X[l]|X[l]|X[l]|X[l]|X[l]|X[l]|X[l]|X[l]|X[l]|X[l]|}
\hline
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 \\\hline
0.36 & 0.44 & 0.48 & 0.42 & 0.24 & 0.17 & 0.11 & 0.15 & 0.24 & 0.10 & 0.08 & 0.10 & 0.06 \\\hline
\end{tabu}
\end{table}

However this generates the following table:

enter image description here

The entries aren't contained in their cells and obviously difficult to read. Am I doing something incorrectly?

New contributor
user9933193 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • welcome to tex.se! apparently cells' contents are to wide to be fit in cells nicely. you should enlarge table width and try to reduce \tabcolsep. please, extend your code sniped to complete small document beginning with \documentclas{...}, following relevant packages (for page layout and table seting) in preamble, your table in document body and ending with \end{documen}. without this document is difficult to help you. – Zarko Apr 16 at 3:09
  • Be careful when using tabu. Read the readme and the open issues here: github.com/tabu-fixed/tabu. – Ulrike Fischer 2 days ago
1

I guess you're writing a two-column document, judging from 0.45\textwidth. Even with \scriptsize, with a 10pt main font size and Times font, a three digit number containing the decimal period occupies 12.25pt.

You have also fourteen times the \arrayrulewidth and the whole lot takes (excluding intercolumn spaces) 165pt. In a standard two-column article class, the column width is 229.5pt and this leaves less than 2.5pt for the intercolumn space.

So you have to reduce the intercolumn space. I show how to do it, but also a different method that avoids computations; without vertical rules, the table is much better and easier to read.

\documentclass[twocolumn]{article}
\usepackage{newtxtext,newtxmath}
\usepackage{booktabs}

\usepackage{tabu} % for the first table

\usepackage{lipsum} % for context

\begin{document}

\lipsum[1]

\begin{table}[h!]
\scriptsize
\caption{Image label frequency}
\label{tab-1}

\setlength{\tabcolsep}{2.4pt}

\begin{tabu} to \columnwidth{ | *{13}{X[c]|} }
\hline
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 \\
\hline
0.36 & 0.44 & 0.48 & 0.42 & 0.24 & 0.17 & 0.11 & 0.15 & 0.24 & 0.10 & 0.08 & 0.10 & 0.06 \\
\hline
\end{tabu}
\end{table}

\begin{table}[h]
\scriptsize
\caption{Image label frequency}
\label{tab-1-again}

\setlength{\tabcolsep}{0pt}% let TeX compute widths
\begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}}*{13}{c}}
\toprule
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 \\
\midrule
0.36 & 0.44 & 0.48 & 0.42 & 0.24 & 0.17 & 0.11 & 0.15 & 0.24 & 0.10 & 0.08 & 0.10 & 0.06 \\
\bottomrule
\end{tabular*}
\end{table}

\lipsum

\end{document}

enter image description here

Your Answer

user9933193 is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.