LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Latex, width of a tabular table? (https://www.linuxquestions.org/questions/programming-9/latex-width-of-a-tabular-table-325885/)

fei 05-22-2005 04:13 AM

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}

kev82 05-22-2005 05:29 AM

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}


fei 05-22-2005 06:28 AM

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.

enemorales 05-22-2005 09:36 AM

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.

fei 05-22-2005 08:16 PM

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?

enemorales 05-23-2005 09:11 AM

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...


All times are GMT -5. The time now is 05:54 PM.