views:

483

answers:

1

I just started to learn latex and now I'm trying to create a table. This is my code:

\begin{table}
\caption{Top Scorers}
\begin{tabular}{ l l }
    \hline
    \bf Goals & \bf Players\\
    \hline
    4 & First Last, First Last, First Last, First Last\\
    3 & First Last\\
    2 & First Last\\
    1 & First Last, First Last, First Last, First Last, First Last, First Last, First Last, First Last, First Last, First Last, First Last, First Last, First Last\\
    \hline
\end{tabular}
\end{table}

The problem is that the table is wider than the page. I was hoping that it would automatically fit to the page like normal text does, but it didn't. How do I tell latex to make the table fit to the page?

+4  A: 

Use p{width} column specifier: e.g. \begin{tabular}{ l p{10cm} } will put column's content into 10cm-wide parbox, and the text will be properly broken to several lines, like in normal paragraph.

You can also use tabular* environment to specify width for the entire table.

See http://web.mit.edu/annakot/MacData/afs/dev/project/tetex-2.0.2/share/texmf/doc/latex/latex2e-html/ltx-68.html.

PiotrLegnica
Do I have to set a fixed size for p{} or can I tell it to use the rest of the space?
Erik B
@Erik: AFAIK you need a fixed size.
PiotrLegnica