Table fixed column width and centering method in Latex

Source: Internet
Author: User
Table fixed column width and center
Method One:
In the introductory area:
\usepackage{array}
\newcolumntype{c}[1]{>{\centering}p{#1}}
In the table, if you need to set a fixed width of a column (assuming the column width is set to 5cm) and centered, the corresponding columnar definition should be set to c{5cm}
When using this method, the line breaks in the table cannot be used with \ \ or \newline, use \tabularnewline.
Method Two:
In the introductory area:
\usepackage{array}
\newcommand{\preservebackslash}[1]{\let\temp=\\ #1 \let\\=\temp}
\newcolumntype{c}[1]{>{\preservebackslash\centering}p{#1}}
\newcolumntype{r}[1]{>{\preservebackslash\raggedleft}p{#1}}
\newcolumntype{l}[1]{>{\preservebackslash\raggedright}p{#1}}
In the table, if you need to set a fixed width of a column (assuming the column width is set to 5cm) and centered, the corresponding columnar definition should be set to c{5cm};
If you need to set a fixed width of a column (assuming the column width is set to 5cm) and left, the corresponding columnar definition should be set to l{5cm};
If you need to set a fixed width of a column (assuming the column width is set to 5cm) and right, the corresponding columnar definition should be set to r{5cm};
Use this method to wrap lines in a table with \ \.
For more information, refer to the documentation for the array macro package.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.