Graphics, Figures & TablesTable - Width of Columns

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

Table - Width of Columns

Post by latexhelp1 »

I have the following table code that is landscaped. I need to use \begin{landscape}to landscape (rather than sidewaystable) and cannot change the geometry or I will have syntax problems with the rest of my file.

I am having problems fitting the numbers in the following table into 1 row. However, I realize I can if I increase the width scaling. It is below at 1.25. I realize I can increase it further, but I would not like to.

Instead, I am wondering if I can change the width of the columns. Specifically, the column (1) does not require as much width as the column (8) because the A is thinner than the HHHHHHHH. Is it possible to have the table such that nothing else in the table changes nor does the geometry and yet there can be more a size to fit such that the width of column 1 would decrease and that of column 8 could increase to accommodate their naturally different needs?

I would very much appreciate any suggestions you have to my code:

Code: Select all

\documentclass[12pt]{article}
\usepackage{rotating}
\usepackage{pdflscape}
\usepackage[flushleft]{threeparttable}
\usepackage[margin=1in, lmargin = 1in]{geometry}
\usepackage[T1]{fontenc}
\usepackage[font=large,labelfont=bf,tableposition=top, textfont=bf]{caption}
\usepackage{longtable}
\usepackage{array}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{mathptmx}
\usepackage[scaled]{helvet}
\usepackage{fix-cm}

\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcommand{\rowstyle}[1]{%
\gdef\currentrowstyle{#1}%
#1\ignorespaces
}
\begin{document}

\begin{landscape}
\begin{table}[!ht]
\caption{Table 1's Caption}\label{table1}
\centering
\begin{threeparttable}
\small
\begin{tabularx}{1.25\textwidth}{l*9{C}C}
\toprule
 & (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8) & (9) & (10) \\ 
  & A & BB & CCC & DDDD & EEEEE & FFFFFF & GGGGGG & HHHHHHH & IIIII & J \\ 
\midrule
 Variable & 0.139*** & 0.034*** & 0.032*** & 0.016*** & 0.109 &  0.053*** & -0.051 & -0.051*** & 0.011*** & -0.002*** \\
\bottomrule\addlinespace
\end{tabularx}
\begin{tablenotes}
\vspace{0.2cm}
\footnotesize{

\item \noindent \hspace{-1.8mm} Notes: 
}
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{landscape}

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

Table - Width of Columns

Post by latexhelp1 »

Hi,

I am just wondering if you have any thoughts to the following situation. I truly appreciate everything that you guys do. I've just been curious for a few days to the solution, and am wondering if there are any issues with my posting so I can help you help me more effectively.

I truly appreciate your help and your patience with my many questions.

Bless you.
latexhelp1 wrote:I have the following table code that is landscaped.
marius63
Posts: 6
Joined: Fri Oct 28, 2011 12:23 pm

Re: Table - Width of Columns

Post by marius63 »

Not sure I understand the issue, but if it is the negative numbers taking two lines then changing the column specs thus seems to work:

\begin{tabularx}{1.25\textwidth}{C C C C C C C c c c c}%l*9{C}C}
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

Table - Width of Columns

Post by latexhelp1 »

Thank you, thank you, thank you! This looks great.

I hope you don't mind me asking, but what is the difference between the C and the c? I'm just trying to understand how what you wrote of C C C ... c c c.. syntax differs from what I originally had of l*9{C}C so I can fix my other tables accordingly.

You are right that I did not like the negative numbers taking two lines. I thought a quick fix, if the following is possible, would be somehow to make the column width for say column (1) (the one with A) thinner and that for column (8) (the one with H) wider. I am just making up numbers here, but say I want the wdith of the former to be 1cm and the latter to be 2cm (or any such numbers that would work out nicely).

My syntax, I think was setting the default to making them the same width, and I just wanted the change the width according to the number of characters in the column. I didn't know if there was a syntax for size-to-fit for the number of characters, or there is a way to specifically request that a certain column be made smaller, or another one be made larger.
That is, whether I can set the widths or whether Latex can compute ideal widths. But somehow, with my syntax, the ideal width was equal spacing and wrapping around the numbers in column 8.

I hope that explanation makes a little clearer what I am looking for help with.

I think your suggestion will work very nicely!!! I am just trying to understand it so I can implement it more widely. I am also just curious what exactly happened.
marius63 wrote:Not sure I understand the issue, but if it is the negative numbers taking two lines then changing the column specs thus seems to work:

\begin{tabularx}{1.25\textwidth}{C C C C C C C c c c c}%l*9{C}C}
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Table - Width of Columns

Post by localghost »

latexhelp1 wrote:[…] I hope you don't mind me asking, but what is the difference between the C and the c? I'm just trying to understand how what you wrote of C C C ... c c c.. syntax differs from what I originally had of l*9{C}C so I can fix my other tables accordingly. […]
If you are struggling with these LaTeX basics, I strongly recommend to do some appropriate reading. My fellow moderator has written a beginner's guide. A sample chapter about typesetting of tables is available on the publisher's web presence [1].

I introduced the »C« column type as solution to one of your earlier questions here [2]. Seems that you don't remember. If you don't need that, just choose one of the regular column types for a »tabular« environment. You will also learn that {*{10}{c}} in the tabular preamble sets up ten columns with centered content.

[1] LaTeX Beginner's Guide Book & eBook | Packt Publishing Technical & IT Book and eBook Store
[2] View topic: Control Table Size


Thorsten
Post Reply