Talk:LaTeX/Tables

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

Is it possible to let a table span multiple pages?--Cinquero 16:03, 14 February 2006 (UTC)

Yes, but you use a special environment (e.g. "longtab" or "supertab") instead of tabular --Mcld 22:49, 21 March 2007 (UTC)


Where is "tutorial4/wrapped.tex wrapped.tex"?

Tutorial4 is here http://www.andy-roberts.net/misc/latex/latextutorial4.html



for the text wrapping, specifying the whole table width with:

\begin{tabular}{width}[pos]{cols}

is probably the better solution than to specify the colums with something like {r |p{3cm}|l|l l} as then the space is distributed better. Don't want to rewrite that whole section though, maybe just note that the tabluar can be opened like that too.


Contents

[edit] indent problem

I'm experiencing this problem: I have a table with a very long column in a report style. I have used the tabular* solution with the fixed table width "\textwidth" ([[1]]. The problem is that the table is indented like the first line of a paragraph. So, if I give it a "\textwidth" width, the table will stretch out the right side. Is it possible to give a width like "\textwidth-\parindent"? -- 12 June 2007

There is LaTeX/Q&A for this... if you just want to remove the indentation, then use \noindent just before your table. Wouldn't it be better to make it float?? Alessio Damato 16:47, 13 June 2007 (UTC)

[edit] Resize problem

I tried the method of resizing a tabular environment with as suggested on this page but it didn't work. Please verify!

I just used the resizing. Works great. Thanks! I used \begin{tabular*}{\textwidth}{|p{0.2\textwidth}|p{0.8\textwidth}|} for two columns (in the text it says p may need tweaking; if you use \textwidth you are relatively safe.). --161.116.83.135 09:56, 18 September 2007 (UTC)
  • It might be useful to state that you need to include the graphicx package in the preamble to use the \resizebox command:
  \usepackage{graphicx}

[edit] Style of tables

All LaTeX books have the weakness to focus on vertical lines too much. They are much discouraged in scientific writing ... something one is not necessarilty trained about. Please talk more about how to present tables properly and talk more about hhlines and cline. This may also help to get LaTeX across to the user more easily and is an essential advantage when compared with word. Smoe 08:35, 27 August 2007 (UTC)

well, edit the page according to your thoughts without any problem. Add some examples of style, too. Alessio Damato 20:28, 27 August 2007 (UTC)
There happens to be an excellent LaTeX package and "thought provoking" essay on the subject of vertical "rules" in tables—read the essay/documentation for booktabs here. I've been planning to include this package here, I'm just too busy at the moment. I'll do it someday in the next week or two (unless someone is antsy and wants feature it here). Other examples that use vertical rules should not be modified, since I'll respect other's decision to use these (I never use vertical rules myself). +mt 05:08, 28 August 2007 (UTC)

[edit] Exporting tables from spreadsheet programs

I would like to see exports from spreadsheet programs here on the page and I am aware of an OOo export as well the wonderful gnumeric export (exports with formatting etc. but is editable also). This might be easy and enough for most users. Here are the links: gnumeric, Calc2LaTeX, Excel2LaTex

I support this. Excel2Latex just saved me a lot of time ... Goetz (talk) 00:10, 13 November 2009 (UTC)

[edit] Tools

If there are any tools that can be used to generate latex tables or convert 'what yo see is what you get' tables into latex (eg gnumeric, calc2latex), it would be nice to list them here at the end (similar to what is done in "Bibtex" section...

[edit] The tabular* environment - controlling table width

in the example with @{...} construct there are second and third column aligned to the right instead of center. Why is it? How should it be correct?

[edit] The tabularx enviroment - X specification

I got an ugly error when trying to use the X cell specification because I didn't realize it was the CAPITAL X. If this is general, and not because of me setting up something in a corky way, maybe this should be made more explicit in the text..? (I use tex live and kate)

Please re-read "except that it has a new column specifier X (in uppercase)" - should be clear? Bumbulski (talk) 19:57, 29 August 2009 (UTC)

[edit] Multiline braces grouping table cells?

Hullo! Does anyone here know how to do the following within a table? Where each of One..Five are in their own cells, and the two Groups are in multirow cells. (The below is bodged together with math arrays.) I'm trying to get the braces to line up and be of similar thickness.


\left.
\begin{array}{l}
One \\
Two \\
Three\\
\end{array}
\right\} Group


\left.
\begin{array}{l}
Four \\
Five \\
\end{array}
\right\} Second Group

I've tried just using larger normal braces, e.g.:

\begin{tabular}{ll}
One & \multirow{3}{*}{{\Big\}} Group} \\
Two & \\
Three & \\
\end{tabular}

...which is okay so long as each grouping is of the same number of rows, but when they're different, and I use \Big and \Huge (for example), the braces look very different.

Any help would be very much appreciated!

Thanks. — Sam Wilson ( TalkContribs ) … 06:44, 23 October 2008 (UTC)

Well, I'm using a slightly-okay method, which still doesn't quite align things correctly if there's multiple different-sized groups:

\newcommand{\threelinebrace}{$\left. \begin{array}{c} \\ \\ \\ \end{array} \right\rbrace$}
 
\begin{tabular}{ll}
One & \multirow{3}{*}{\threelinebrace Group} \\
Two & \\
Three & \\
\end{tabular}

If anyone's got a better idea, I'd love to hear it. — Sam Wilson ( TalkContribs ) … 07:12, 23 October 2008 (UTC)

Try this, it works for me:

\begin{equation}
e_i= \left\{
\begin{tabular}{ll}
(0,0,0)&i=0 \\
(-1,0,0),(0,-1,0),(0,0,-1)& i=1-6\\ 
(-1,-1,0),(-1,0,-1),(0,-1,-1)&i=7-18
\end{tabular}
\right.
\end{equation}

you need to use the invisible \right. to close the \left\{ .

[edit] colors, line types

I think it would be useful to mention table cell coloring using colortab or colortbl. Also you could mention the arydshln package which allows dotted/dashed vertical lines. In linguistics, the dotted vertical lines are necessary in Optimality Theory tableaux to show that the ordering of constraints (displayed in columns) is not strictly ordered. Grayed out cells show that the data in the cells are irrelevant (although it is becoming less popular to use this currently because it doesnt photocopy so well). Anyway, knowing how to make a table in LaTeX is worthless for me if I can't get the dashed vertical lines. peace 76.119.228.130 (talk) 08:19, 18 January 2009 (UTC)

Scaling the size of a table is simple with a construct like this:

\scalebox{0.5}{
\begin{tabular}{|c|c|c|c|} \hline
 unit & A [x] & B [y]  & C [z] & \hline
 value& 100   &  10150 & 1904  & \hline
\end{tabular}
} 

compared to the normal one

\begin{tabular}{|c|c|c|c|} \hline
 unit & A [x] & B [y]  & C [z] & \hline
 value& 100   &  10150 & 1904  & \hline
\end{tabular}


also works in tables, I use it to adjust the final layout if I want to have a certain table to appear on a certain page, it's like scaling images... just try it, i cannot upload images at the moment

[edit] surrounding space

I haven't found a single page yet that explains how to manipulate the space above and below a table definition. By default, for instance, an inline tabular in a paragraph will add lots of unwanted vertical space above it, but there do not seem to be any explanations on how to set that space to 0pt

What are tabular's extended parameters? which apply? which don't? That information belongs in an explanation on the tabular environment, but is still missing here (I can't add it, since I just don't know, I'm just scowering the internet trying to find out how to tell latex what I want it to do)