Did you know LQ has a Linux Hardware Compatibility List?
 Home Forums HCL Reviews Tutorials Articles Register Search Today's Posts Mark Forums Read
 LinuxQuestions.org Latex, width of a tabular table?
 Programming This forum is for all programming questions. The question does not have to be directly related to Linux and any language is fair game.

Notices

 05-22-2005, 04:13 AM #1 fei Member   Registered: Jun 2003 Distribution: Ubuntu, Debian Posts: 40 Rep: Latex, width of a tabular table? I have a tabular table, but it's too wild. I want to know how to narrow the width of the tabular table. Can anyone help me with this? Thanks! the code is like: \begin{table} \begin{tabular}{|c|c|} ..... ..... \begin{tabular} \caption{..........} \end{table}
 05-22-2005, 05:29 AM #2 kev82 Senior Member   Registered: Apr 2003 Location: Lancaster, England Distribution: Debian Etch, OS X 10.4 Posts: 1,263 Rep: I've always put tables in figures, I didn't know about the table environment. Does it do anything better than the figure environment? Anyway, what you want is the tabular* envirnment, it takes a mandatory width argument, something like Code: \begin{table} \begin{tabular*}{8cm}{|c|c|} ..... ..... \end{tabular*} \caption{..........} \end{table}
 05-22-2005, 06:28 AM #3 fei Member   Registered: Jun 2003 Distribution: Ubuntu, Debian Posts: 40 Original Poster Rep: Image can be scaled quite easily. The problem of scaling tabular is that the words in the tabular are not scaled.. I need to change the font size in order to narrow down the tabular width.
 05-22-2005, 09:36 AM #4 enemorales Member   Registered: Jul 2004 Location: Santiago, Chile Distribution: Ubuntu Posts: 410 Rep: Hi, I think that the advantage is that they are numerated independently, so you can use commands like \tableoftables intead of \tableoffigures (don't remember the exact commands, but that's the idea). About the question itself, you can use p{10cm} to define a column of fixed width. LaTeX will put the content of a cell in different lines when needed.
 05-22-2005, 08:16 PM #5 fei Member   Registered: Jun 2003 Distribution: Ubuntu, Debian Posts: 40 Original Poster Rep: Sorry. I don't quite get what you said. So, what's the command \tableoftables? I cann't find that knd of command. And how do I use the command p{10cm}? Where should I put it in the tabular table?
 05-23-2005, 09:11 AM #6 enemorales Member   Registered: Jul 2004 Location: Santiago, Chile Distribution: Ubuntu Posts: 410 Rep: Sorry, I think I didn't explain myself properly. First, I answered kev82. I said that he puts always tables inside the figure environment because he finds no advantage in using the table environment. AFAIK, the good thing about using the table environment is that the numbers of tables and figures are independent: if you habe several figures in a document, you can use the comand \listoffigures and LaTeX will create the table of figures, ie something like Figure 1 ................. 3 Figure 2 ................ 5 ... If you put tabulars inside figures and you want to use this feature, tables and figures will share the numbers and a table will appear in the table of figures, which is not very nice. At the moment I wrote the other post I didn't have the time to check the command name to do this, which is \listoffigures (and not \tableoffigures, as i guessed). A analogous table of tables can be obtained with the \listoftables command (and not \tableoftables, which doesn't exist). About your original question, the p{10cm} is used to define a tabular column, so you can write something like this: Code: \begin{table} \begin{tabular}{|p{10cm}|p{5cm}|} ... \end{tabular} \caption{This is a table with two columns.} \label{tbl:TWTC} \end{table} Then LaTeX will create the table with fixed colum widths of size 10cm and 5cm, resp. and, as I wrote before, it will put the content of a cell in differents rows of the table automatically if the size of the text is two big. One important thing is that, unless you have some particular reason to have your table as a floating body and you don't use the \listoftables command, you don't need to use the table environment and can omit the \begin{table} and \end{table} commands. I hope I made myself clearer now. Sorry for the last post...