Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to set up a tabular system like the one below, but latex does not seem to want to work with different number of elements in each row. Any way to fix this ?

|Prime numbers| |   Integers  | | Square numbers  | | Difference  |
| p |           | n_1 | | n_2 | | n_1^2 | | n_2^2 | |n_1^2 - n_2^2|
| 3 |           |  2  | |  1  | |  2^2  | |  1^1  | |      3      |

Anyone have a good method for seting up sucha a table? =)

share|improve this question

1 Answer 1

up vote 6 down vote accepted

You seem to want \multicolumn, probably combined with the array package to do soemthing like

\documentclass{article}
\usepackage{array,booktabs}
\begin{document}
\begin{tabular}{*{6}{>{$}c<{$}}}
  \toprule
  \multicolumn{1}{c}{Prime numbers} &
  \multicolumn{2}{c}{Integers} &
  \multicolumn{2}{c}{Square numbers} &
  \multicolumn{1}{c}{Difference} \\
  \midrule
  p & n_1 & n_2 & n_1^2 & n_2^2 & n_1^2 - n_2^2 \\
  3 &   2 &   1 &   2^2 &   1^1 &       3       \\
  \bottomrule
\end{tabular}
\end{document}
share|improve this answer
    
Thanks! Thats almost what I need , so close. Only problem now is that the rows are nor completely aligned. I feel that they are a bit left centered compared to the titles Also they are a bit cramped vertically. Will see if I can add some space on my own Thanks again –  N3buchadnezzar Oct 2 '11 at 9:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.