Tables · Bảng
Tables
- A table uses the
tabularenvironment. You first describe the columns:
{l c r}means three columns: left-aligned, centred, right-aligned.
Bảng
- Một bảng sử dụng môi trường
tabular. Đầu tiên bạn mô tả các cột:
\begin{tabular}{l c r}
left & centre & right \\
\end{tabular}
{l c r}nghĩa là ba cột: left-aligned (căn trái), centred (căn giữa), right-aligned (căn phải).
Rows and cells
- Inside,
&jumps to the next column and\\starts a new row:
- The number of cells in each row must match the number of columns you declared.
Hàng và ô
- Bên trong,
&nhảy sang cột tiếp theo và\\bắt đầu một hàng mới:
\begin{tabular}{l l}
Apple & 5 \\
Banana & 3 \\
\end{tabular}
- Số lượng ô trong mỗi hàng phải khớp với số cột bạn đã khai báo.
Lines (optional)
- Add
|between column letters for vertical lines, and\hlinefor horizontal ones:
- For a cleaner look, professionals use the
booktabspackage instead of many lines.
Các đường kẻ (tùy chọn)
- Thêm
|giữa các chữ cái cột để có đường kẻ dọc, và\hlinecho đường kẻ ngang:
\begin{tabular}{|l|l|}
\hline
Apple & 5 \\ \hline
\end{tabular}
- Để có giao diện sạch sẽ hơn, các chuyên gia sử dụng gói
booktabsthay vì nhiều đường kẻ.
Common mistakes
tabularneeds a column spec like{lcr}; separate cells with&and end rows with\\.- The number of
&per row must fit the column spec.
Lỗi thường gặp
tabularcần một cấu hình cột giống như{lcr}; tách các ô bằng&và kết thúc các hàng bằng\\.- Số lượng
&mỗi hàng phải vừa với cấu hình cột.
Build a small two-column table with \begin{tabular}{l l}. Separate the two cells in a row with &, and end each row with \\. Add the rows for Bob (30) and Mei (25). · Xây dựng bảng nhỏ hai cột với \begin{tabular}{l l}. Tách hai ô trong một hàng với &, và kết thúc mỗi hàng với \\. Thêm các hàng cho Bob (30) và Mei (25).
Add lines to the table. Put \hline at the top, after the header row, and at the bottom, and use |l|l| in the column spec for vertical lines. · Thêm đường kẻ vào bảng. Đặt \hline ở trên cùng, sau hàng tiêu đề, và ở dưới cùng, và sử dụng |l|l| trong mô tả cột cho các đường kẻ dọc.