
How to draw table borders in LaTeX
Take an example of two column table.
\begin{tabular}{cc}
Book & 30 \\
Pen & 5
\end{tabular}

If you add a vertical bar |
to cc
;
\begin{tabular}{c|c}
Book & 30 \\
Pen & 5
\end{tabular}
\begin{tabular}{|c|c}
Book & 30 \\
Pen & 5
\end{tabular}
\begin{tabular}{|c|c|}
Book & 30 \\
Pen & 5
\end{tabular}
LaTex draws the borders of table or cells.

Horizontal line
The command \hline
draws a horizontal line in a table.
\begin{tabular}{|c|c|}
\hline
Book & 30 \\
Pen & 5
\end{tabular}
\begin{tabular}{|c|c|}
\hline
Book & 30 \\
\hline
Pen & 5
\end{tabular}
\begin{tabular}{|c|c|}
\hline
Book & 30 \\
\hline
Pen & 5 \\
\hline
\end{tabular}

Let's see the last table in the above example. The row Pen & 5
has \\
unlike other two tables. If removing \\
, LaTeX throws an error.
Comments
Powered by Markdown