7

I generated this table but it's width exceeds the line width as i am working in two column paper And i need it to fit only in one column, Any help ?

enter image description here

\begin{table}[t]
\centering
\begin{tabular}{|c|c|c|}
\hline
Generated Cluster Number & Real Cluster Number & Ratio of mapped spikes \\
\hline
         2 &          3 &     0.4233 \\
\hline
         3 &          2 &     0.3545 \\
\hline
         4 &          1 &     0.8463 \\
\hline
         5 &          1 &     0.3432 \\
\hline
         6 &          3 &     0.6345 \\
\hline
         7 &          2 &     0.2349 \\
\hline
         8 &          2 &     0.4267 \\
\hline
\end{tabular}
\label{tab:template}
\end{table}
6

You can use the starred version of tabular environment and a p{} modifier for column alignment with custom size, based on \linewidth.

\documentclass[twocolumn]{article}
\usepackage{booktabs}
\usepackage{lipsum}
\begin{document}
\begin{table}[t]
\centering\small
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}p{0.3\linewidth}p{0.3\linewidth}p{0.3\linewidth}@{}}
\toprule
Generated Cluster Number & Real Cluster Number & Ratio of mapped spikes \\
\midrule
         2 &          3 &     0.4233 \\
         3 &          2 &     0.3545 \\
         4 &          1 &     0.8463 \\
         5 &          1 &     0.3432 \\
         6 &          3 &     0.6345 \\
         7 &          2 &     0.2349 \\
         8 &          2 &     0.4267 \\
\bottomrule
\end{tabular*}
\label{tab:template}
\end{table}
\lipsum[1-5]
\end{document}

enter image description here

  • if the number of digits is always the same in each column, a centered format would look nicer, and also avoid the very wide spacing in the first line of the middle heading, which is confusing. (it looks like it could mean "cluster ratio ...".) – barbara beeton Apr 8 '13 at 12:38
8

I would suggest stacking the headings, and perhaps eliminate the duplication of "Number", since it should be obvious:

enter image description here

\documentclass[twocolumn]{article}
\usepackage{booktabs,lipsum}% http://ctan.org/pkg/{booktabs,lipsum}
\begin{document}
\lipsum[1]

\begin{table}
  \centering
    \begin{tabular}{ccc}
        \toprule
        Generated & Real & Ratio of \\
        cluster & cluster & mapped spikes\\
        \midrule
        2 & 3 & 0.4233 \\
        3 & 2 & 0.3545 \\
        4 & 1 & 0.8463 \\
        5 & 1 & 0.3432 \\
        6 & 3 & 0.6345 \\
        7 & 2 & 0.2349 \\
        8 & 2 & 0.4267 \\
        \bottomrule
    \end{tabular}
  \caption{A table}
\end{table}

\lipsum[2-5]
\end{document}

I've used booktabs, which inherently discourages the use of vertical lines. However, the example would work even without if you reinstate the vertical and horizontal rules. booktabs just provides the necessary eye-candy for tabular.

Your Answer

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.