Table
In LaTeX we use tabular command to typeset a table.
......
\end{tabular}
The codes for columns are defined as follows
l left-alignment
r right-alignment
c centre-alignment
| for vertical line
& is used to separate columns
\\ for end of a row
\newline for a new line within a cell
\newline for a new line within a cell
\hline for a horizontal line.
\cline{i-j} inserts a partial horizontal line between column i and j
Ex. {ll} (i.e. left left ) is used to create 2 columns with left-alignment text without vertical lines , whereas {|l|r|} (i.e. left right ) for 2 columns. The first column is left aligned and second column is right aligned with vertical lines.
Tabular Code and output
\documentclass[options]{Article}
\begin{document}
\begin{tabular}{|l|r|}
RAM & ROM \\
Printer & Plotter \\
Keyboard & Mouse \\
\end{tabular}
\end{document}
\documentclass[options]{Article}
\begin{tabular}{|r|l|}
\hline
One & Two \\
\cline{2-2}
Three & Four \\
\hline \hline
Hello123 & Done \\
\hline
\end{tabular}
\end{document}
Output Ex. 3 |
\documentclass[options]{Article}
\begin{document}
\begin{tabular}{|r|r|r|r|}
\hline
Item & 2012 & 2013 & 2014 \\
\hline
Desktop & 23 & 25 & 26 \\
\hline
Laptop & 53 & 55 & 86 \\
\hline
Monitor & 13 & 85 & 28 \\
\hline
\end{tabular}
\end{document}
Ex. 4.
Output Ex. 4 |
\usepackage{multirow}
\begin{document}
\begin{tabular}{l|rrr}
\multicolumn{4}{c}{Table 4}\\
\hline
\multirow{2}{4em}{Item} & \multicolumn{3}{c}{Year} \\
\cline {2-4}
& 2012 & 2013 & 2014 \\
\hline
Desktop & 23 & 25 & 26 \\
\hline
Laptop & 53 & 55 & 86 \\
\hline
Monitor & 13 & 85 & 28 \\
\end{tabular}
\end{document}
No comments:
Post a Comment