Tables
LaTeX Lesson 8 2:00 English narration · English + 中文 subtitles burned in
Chapters
Transcript
A table is the tabular environment, and it takes something no other environment has taken so far: a column specification, in braces after the name.
表格是 tabular 环境,而它需要一样此前任何环境都不需要的东西: 一个"列格式",写在环境名后面的花括号里。
Those letters are not decoration.
那些字母不是装饰。
Each letter IS a column, and the letter says how that column is aligned — l for left-aligned, r for right-aligned, c for centred.
每一个字母就是一列,而这个字母说明那一列怎么对齐—— l 是左对齐,r 是右对齐,c 是居中。
Two letters here, so two columns.
这里有两个字母,所以是两列。
Inside, the content is separated by the two characters you met last lesson.
在里面,内容由你上一课见过的那两个字符分隔。
An ampersand jumps to the next column.
& 跳到下一列。
Two backslashes start a new row.
两个反斜杠开始新的一行。
If that feels familiar it should: it is exactly what a matrix used, so it is one pattern, learned once, and used in both places.
如果这感觉很眼熟,那就对了: 矩阵用的正是同一套写法, 所以这是一个模式,学一次,两处都能用。
Lines are optional and you add them where you want them: hline draws a horizontal rule at that point in the table, and a pipe between letters in the spec draws a vertical one.
线是可选的,你想在哪儿加就在哪儿加: \hline 在表格的那个位置画一条横线, 而在格式字母之间加一个竖线符号,就会画一条竖线。
A word of taste, though — a table boxed in on every side is harder to read than a clean one, and a single rule under the heading row is usually enough.
不过提一句品味上的建议—— 四面都框起来的表格比干净的表格更难读, 通常在表头下面来一条线就够了。
One error is almost guaranteed at some point: a row with more cells than the spec declared.
有一个错误你早晚必犯:某一行的格数比列格式声明的多。
You said two columns; this row has three, so the third has nowhere to go, and LaTeX stops with an extra-alignment-tab message.
你说了两列;这一行有三格,所以第三格无处可去, LaTeX 就会停下来,报一个"多余的对齐符"的消息。
The fix is one or the other — add a letter to the spec, or remove the cell.
修法二选一——要么在格式里加一个字母,要么把那一格去掉。
Four things to take with you.
带走四点。
One: the spec has one letter per column — l, r or c.
第一:列格式每列一个字母——l、r 或 c。
Two: an ampersand moves to the next column.
第二:& 移到下一列。
Three: two backslashes start a new row.
第三:两个反斜杠开始新的一行。
Four: hline draws a rule, and use them sparingly.
第四:\hline 画一条线,而且要少用。
Now build your table and press Run.
现在把你的表格搭出来,然后按 Run。