Wednesday, May 22, 2013

Multirow and multicolumn spanning with latex tables by Dr. Andrew J. Page


http://www.andrewjpage.com/?archives/43-Multirow-and-multicolumn-spanning-with-latex-tables.html

The easiest way to do multirow and multicolumn spanning in latex is to use the package multirow. Just put
\usepackage{multirow} at the top of your latex file.



Above is a simple example of this in action.
\begin{tabular}{|l|l|l|} \hline
\multicolumn{3}{|c|}{Schedulers} \\ \hline
\multirow{3}{*}{Immediate} & RR & Round Robin \\
& EF & Earliest First \\
& LL & Lightest Loaded \\ \hline
\multirow{4}{*}{Batch} & MM & Min-Min \\
& MX & Max-Min \\
& DL & Dynamic Level \\
& RC & Relative Cost \\ \hline
\multirow{4}{*}{Evolutionary} & PN & This paper \\
& ZO & Genetic Algorithm\\
& TA & Tabu search~\cite{GLOV1986j}\\
& SA & Simlulated Annealing \\ \hline
\end{tabular}


The main things to note are, to span multiple columns in a latex table you just use \multicolumn followed by the number of columns to span and how you want it positioned, e.g. l for left, r for right, c for centered. Spanning multiple rows in a latex table is the same, except using \multirow followed by the number of rows to span, and how you would like it positioned. * basically means best fit. Remember that the first element of each row needs to be empty, since you have some piece of information spanning multiple rows.

No comments:

Post a Comment