Table of Contents
Newsgroups: comp.text.tex Date: Thu, 25 Mar 2004 05:00:51 GMT
Below is a summary of width of the text in (La)Tex, and my question.
If the paper size/margins might be different, rather than specifying an explicit dimension, one can use two tex commands, \textwidth and/or \linewidth.
\textwidth is the normal width of the text on a page. It should generally be changed only in the preamble.
\linewidth is the width of lines in the current environment. Normally equal to \textwidth, it may be different within an environment such as list or quote environments.
The \linewidth can be further divided up. For example, to define a table which left column takes up 40% of the space, use
\begin{tabular}{p{0.4\linewidth}p{0.6\linewidth}} \end{tabular}
Now here is my question, if I want to put table in table, for example, still, to define a table which left column takes up 40% of the space, but this time the table is in the right column, what is the best way to do?
T
> \begin{tabular}{p{0.4\linewidth}p{0.6\linewidth}} > \end{tabular}
This will get you an overfull hbox since you don't account for the column spacing. (And of course you should have no indentation in that line.)
So either suppress column spacing (using @{}) in the relevant places in the table layout definition) or use the tabularx package.
> Now here is my question, if I want to put table in table, for > example, still, to define a table which left column takes up 40% > of the space, but this time the table is in the right column, what > is the best way to do?
Have you tried just nesting the tables? It should do what you want; if not, what's the problem? Don't forget posting a minimal example of what you did in that case.
Thomas
> I guest this is the reason why the table spread over to the next > column... Can I say something like > \begin{tabular}{p{0.4\linewidth-0.5\columnspace}p{0.6\linewidth-0.5\columnspace}}
yes, if you've loaded the calc package.
Robin
> > ... suppress column spacing (using @{}) in the relevant places in > > the table layout definition) ... > > Could you show me how to do it?
\begin{tabular}{@{}p{0.4\linewidth}@{}p{0.6\linewidth}@{}}
If you insist on vertical rules (which is a Bad Thing, for more on this read the booktabs package documentation) or need some space between the columns (which you will if they contain just text), you're better off using the tabularx package since then you don't need to know how much of \linewidth is really left for the columns:
\usepackage{tabularx} % in the preamble
Read the tabularx package documentation for more information.
Thomas
> \begin{tabular}{@{}p{0.4\linewidth}@{}p{0.6\linewidth}@{}}
one '@{}' at very first is enough: |
+
T
LaTeX normally sets the width of the tabular environment to "natural" width, i.e., determined from the contents of the columns. For narrow tables it is sometimes more pleasing to make them wider.
The 'tabular*' environments allows for setting a width; however, it is necessary to have rubber space between columns that can expand to the specified width. This can often be most easily accomplished by using an which sets the table width to 75% of the text width. This example also centers the table.
\begin{center} % put inside center environment \begin{tabular*}{0.75\textwidth}% {@{\extracolsep{\fill}}cccr} label 1 & label 2 & label 3 & label 4 \\ \hline % put a line under headers item 1 & item 2 & item 3 & item 4 \\ ... \end{tabular*} \end{center}