Text FormattingWeird Results in Table using Column Specifications

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

Weird Results in Table using Column Specifications

Post by Singularity »

Th first table below works fine. In the second talbe, I use column specification, per these instructions, so the column will appear in math mode and get very strange results. Latex moves the double vertical column four columns to the right and no longer prints the first four vertical lines.

Code: Select all

	\begin{tabular}{|r||r|r|r|r|r|r|}
		\hline
		+ & 0 & 1 & 2 & 3 & 4 & 5 \\
		\hline \hline
		0 & 0 & 1 & 2 & 3 & 4 & 5 \\ \hline 
		1 & 1 & 2 & 3 & 4 & 5 & 0 \\ \hline 
		2 & 2 & 3 & 4 & 5 & 0 & 1 \\ \hline 
		3 & 3 & 4 & 5 & 0 & 1 & 2 \\ \hline 
		4 & 4 & 5 & 0 & 1 & 2 & 3 \\ \hline 
		5 & 5 & 0 & 1 & 2 & 3 & 4 \\ \hline 
	\end{tabular}
	\hspace{20mm}
	\begin{tabular}{|>{$}r<{$}||r|r|r|r|r|r|}
		\hline
		+ & 0 & 1 & 2 & 3 & 4 & 5 \\
		\hline \hline
		0 & 0 & 1 & 2 & 3 & 4 & 5 \\ \hline 
		1 & 1 & 2 & 3 & 4 & 5 & 0 \\ \hline 
		2 & 2 & 3 & 4 & 5 & 0 & 1 \\ \hline 
		3 & 3 & 4 & 5 & 0 & 1 & 2 \\ \hline 
		4 & 4 & 5 & 0 & 1 & 2 & 3 \\ \hline 
		5 & 5 & 0 & 1 & 2 & 3 & 4 \\ \hline 
	\end{tabular}
Anyone understand why? How do I fix?
Thanks.
Attachments
Capture.PNG
Capture.PNG (22.54 KiB) Viewed 1872 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Weird Results in Table using Column Specifications

Post by Stefan Kottwitz »

Hi,

obviously you did not load the array package, which is required for this syntax. Insert into your preamble:

Code: Select all

\usepackage{array}
Stefan
LaTeX.org admin
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

Re: Weird Results in Table using Column Specifications

Post by Singularity »

Ahh. Much better.
Thanks.
Post Reply