Basic examplesThis example shows how to create a simple table in LaTeX. It is a three-by-three table, but without any lines.
- \begin{tabular}{ l c r }
- 1 & 2 & 3 \\
- 4 & 5 & 6 \\
- 7 & 8 & 9 \\
- \end{tabular}
复制代码
|

|
Expanding upon that by including some vertical lines:
- \begin{tabular}{ l | c || r }
- 1 & 2 & 3 \\
- 4 & 5 & 6 \\
- 7 & 8 & 9 \\
- \end{tabular}
复制代码
|

|
To add horizontal lines to the very top and bottom edges of the table:
- \begin{tabular}{ l | c || r }
- \hline
- 1 & 2 & 3 \\
- 4 & 5 & 6 \\
- 7 & 8 & 9 \\
- \hline
- \end{tabular}
复制代码
|

|
And finally, to add lines between all rows, as well as centering (notice the use of the center environment - of course, the result of this is not obvious from the preview on this web page):
- \begin{center}
- \begin{tabular}{ l | c || r }
- \hline
- 1 & 2 & 3 \\ \hline
- 4 & 5 & 6 \\ \hline
- 7 & 8 & 9 \\
- \hline
- \end{tabular}
- \end{center}
复制代码
|

|
- \begin{center}
- \begin{tabular}{ | l || c ||| r }
- \hline
- 1 & 2 & 3 \\ \hline
- 4 & 5 & 6 \\ \hline \hline
- 7 & 8 & 9 \\
- \hline
- \end{tabular}
- \end{center}
复制代码
|

|
- \begin{tabular}{|r|l|}
- \hline
- 7C0 & hexadecimal \\
- 3700 & octal \\ \cline{2-2}
- 11111000000 & binary \\
- \hline \hline
- 1984 & decimal \\
- \hline
- \end{tabular}
复制代码
|

|