Below is an example of a table with various forms of cell alignments. Explanations for the formatting is given in the cells. The Wiki did on a number on my formatting but you should be able to copy and paste this file into a LaTeX editor and have it compile correctly. Enjoy! -Peter

\documentclass{article}
\pagestyle{empty}
\begin{document}


\begin{table}
\caption{This table shows the functionality of the commands
\texttt{$\backslash$multicolumn\{\}\{\}\{\}}, \texttt{$\backslash$vline},
and \texttt{$\backslash$parbox\{\}\{\}}, and it shows how
helpful it can be to determine the total number of
columns before you begin creating your table.}
	\begin{center}
		\begin{tabular}{|p{4cm}|c|c|l|}\hline
			\multicolumn{3}{|c|}{Here are three columns}
& One column\\ \hline
			One column & \multicolumn{2}{|c|}
{Two columns} & One column\hspace{3mm} \vline \hspace{3mm}
split with \texttt{$\backslash$vline}\\ \hline
			\multicolumn{4}{|c|}{Hint:
Use \texttt{$\backslash$hspace} to move text around
on either side of \texttt{$\backslash$vline}}\\ \hline
			\multicolumn{4}{|l|}{\hspace{10mm}
Use \hspace{10mm} \vline \hspace{10mm} \texttt{$\backslash$vline}
to split columns \hspace{10mm} \vline \hspace{5mm} wherever
\hspace{3mm} \vline \hspace{3mm} you feel like}\\ \hline
			To have your cell fit a paragraph,
set the width of the column. Do this in the curly braces
following the \texttt{$\backslash$begin\{tabular\}} command,
which is where you tell \LaTeX \ how to format the columns.
Use the command \texttt{p\{length\}}, where \em length \em
is specified in inches, centimeters, or whatever you like.
For example, this table has the following column formatting:
\texttt{$\backslash$begin\{tabular\} 
\{$\mid$p\{4cm\}$\mid$c$\mid$c$\mid$l$\mid$\}}.
Pretty nice, right? & \multicolumn{3}{|r|}
{Right aligned multicolumn}\\ \hline
			\multicolumn{3}{|c|}{Three columns}
& \parbox{5.5cm}{The problem with the paragraph above is
that it requires the entire column to have a determined length.
What if you just have one row that you're concerned with?
That's when you use the \texttt{$\backslash$parbox\{\}\{\}}
command. The first set of curly braces is where you specify
the width of the box. This box has a width of 4cm. The second
set of curly braces is for your text. Like this text here!
This allows you to set the column as right justified, left
justified, or centered, and have the \texttt{$\backslash$parbox}
be it's own thing. Also, notice how the text in the adjacent
cell is vertically centered when you use \texttt{$\backslash$parbox}}\\ \hline
			A row with & all the & original & cell formatting\\ \hline
		\end{tabular}
	\end{center}
\end{table}

\end{document}


Page last modified on February 13, 2008, at 03:55 PM