Wednesday, May 4, 2011

Latex: how to control the column width of a table

Latex will automatically adjust the width of a cell in a table, but it will not consider the width of the page, so sometimes parts of the table are out of the page. If you want to control the column width of a table, you may want to use p option instead of l, c or r for left, center or right alignment.


For example:


\begin{table}[ht]
\centering
\begin{tabular}{|c|p{2cm}|p{1cm}|}
\hline
a & bb & c\\
\hline
\end{tabular}
\end{table}

Good luck!

11 comments:

  1. Many thanks for your post. Saved my day^^

    ReplyDelete
  2. Thank you for the post. this is very useful for me

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. https://en.wikibooks.org/wiki/LaTeX/Tables

    ReplyDelete
  5. Wow, thanks so much. That saved my life today!!
    Thanks!

    ReplyDelete
  6. Thanks! Saved me so much time!!!

    ReplyDelete
  7. You made some first rate factors there. I seemed on the internet for the problem and found most individuals will go along with with your website. gsn casino

    ReplyDelete