Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In the following table, the numbers take up too much room. I do not want to landscape the table because there are too many rows.

So, I'd like to do both of the following:

  1. Create more space between some of the columns. Especially if some columns don't require as much width, I'd like to know whether it is better that I manually set this space in order to optimize.
  2. Shift the table to both the left and right in the process. When I adjust the \textwidth, that just moves it to the right. I'd like the table to still remain centered within the page.

I'd like for the contents to be centered within each column as they are with the current code.

I see a similar posting, but I don't know how to incorporate the results and if that is exactly what I'm trying to do: Adding space between columns in a table

\documentclass[12pt,english]{article}
\usepackage{longtable}
\usepackage{fullpage}
\usepackage{times}
\usepackage[flushleft]{threeparttable}
\usepackage[font=large,labelfont=bf,tableposition=top,textfont=bf]{caption}
\usepackage{tabularx}
\usepackage{booktabs}
\newcolumntype{C}{>{\centering\arraybackslash}X}

\begin{document}

\clearpage \newpage
\begin{table}[!ht]
\caption{Table Title}
\def\arraystretch{1.05}
\vspace{-0.2cm}
\begin{threeparttable}
\small
\begin{tabularx}{\textwidth}{l*{10}{C}}
\hline \hline \addlinespace
 & (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8) & (9) & (10) \\  
Variable Name & 1234566 & 6543216 & 2233456 & 6655432 & 1830349 & 1234532 & 2532534 & 838285 & 123456 & 1285838 \\
\hline \hline \addlinespace
 \end{tabularx}
\begin{tablenotes}
\vspace{0.1cm}
\footnotesize{

\item \noindent \hspace{-1.8mm} Notes: 

 \noindent Sources: 
 }
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document}
share|improve this question
add comment

2 Answers

Here are my suggestions:

  • Insert the command \setlength\tabcolsep{3pt} to cut the amount of intercolumn whitespace in half. (The default value of this parameter is 6pt.)
  • Replace the instruction \small (immediately after \begin{threeparttable}) with \footnotesize. (This also lets you get rid of the subsequent \footnotesize command.)
  • Eliminate the vertical whitespace before the first column and after the final column by changing the tabularx setup as follows:

    \begin{tabularx}{\textwidth}{@{}l*{10}{C}@{}}
    

    (note the two new @{} elements).

With these changes, I manage to get the table to fit into the allocated textblock width. My papersize is US Letter; if yours is A4, you'll probably need to reduce the tabcolsep macro's value further, to 2pt.

Separately, since you're already loading the booktabs package, why don't you also replace the hideous \hline\hline commands with \toprule and \midrule, respectively. (This also lets you get rid of the \addlinespace instructions.)

enter image description here

Please note that the package times is obsolete. I suggest you load the package mathptmx instead -- unless you really want to mix Times New Roman as the text font and Computer Modern as the math font...

Addendum: On the subject of changing the width of the text block: Have a look at this answer for an example of how one may use the geometry package's commands \newgeometry and \restoregeometry to achieve this objective.

share|improve this answer
    
Thank you! First, where should I insert: \renewcommand{\tabcolsep}{3pt} Second, does the \small v.s. \footnotesize change the size of the text? –  J G Feb 15 '12 at 23:00
    
Thank you so much for your help. It is incredible. I am so grateful. This code also doesn't so exactly what I had initially inquired about of stretching the table to the margins. I would not like to change the font size in the process. –  J G Feb 15 '12 at 23:17
    
The former command should be inserted anywhere in the preamble if you want it to apply to all tabular environments, or in a TeX group (delimited by braces) if you want it to apply only locally, i.e., within the scope of the braces. The second command, \footnotesize, applies to all text until the end of the environment it's embedded in -- in the present case, a figure environment. –  Mico Feb 15 '12 at 23:20
    
Thank you Mico! These answers are incredibly helpful. I am still wondering about whether the table can be stretched into the margins. –  J G Feb 15 '12 at 23:28
    
About your second comment: I'd say you have to make a trade-off between two (minor) evils: destroying typographic elegance (by changing the width of the text block locally) and risking diminished legibility of the table's contents (by choosing a font size thaw's too small to decipher). Given that the main text font size is 12pt, \footnotesize works out to 10pt, which shouldn't imperil legibility. Hence my (implied) suggestion no to mess with changing the width of the text block... –  Mico Feb 15 '12 at 23:30
show 3 more comments

In addition to what @mico said I don't see why you want to use tabularx here. Your example fitted within the measure if i changed it to

 \setlength\tabcolsep{1pt}
 \begin{tabular}{l*{10}{l}}

If you really need to extend into the margins just for one table then the plain tex \centerline is a quick and easy way of doing so.

\centerline{\begin{tabular}{l*{12}{l}}
\hline \hline \addlinespace
 & (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8) & (9) & (10) &(11)&(12) \\   
Variable Name & 1234566 & 6543216 & 2233456 & 6655432 & 1830349 & 1234532 & 2532534 & 838285 & 123456 & 1285838 \\
\hline \hline \addlinespace
 \end{tabular}}
share|improve this answer
    
Thank you so much for your help. One of the things I use tabularx is because I can add \newcolumntype{C}{>{\centering\arraybackslash}X}. I do that because I want the numbers cenetered within the column. Is that possible to do within the tabular format? Could I use the same \newcolumntype{C}, a different one? –  J G Feb 15 '12 at 23:55
    
tabularx columns are all about linebreaking to achieve the calculated width (they are p columns in disguise, so not particularly suited for numbers. dcolumn (which is incredibly old) is designed for that, or one of the packages produced since. –  David Carlisle Feb 15 '12 at 23:58
    
@JG: If your objective is to center the numbers within a column, why not just use the c column type? –  Mico Feb 16 '12 at 0:03
    
agreed with @mico If you just want to centre the numbers just use c dcolumn is for aligning on the decimal point if that's what you want. –  David Carlisle Feb 16 '12 at 0:07
1  
exactly as in the code in my answer, but with c rather than l if you want centering. –  David Carlisle Feb 16 '12 at 1:17
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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