2

The first row in my longtable-environment should be left-aligned and only have a specific width. The other rows should be right-aligned. I get the error Extra alignment tab has been changed to \cr 1 & if I use >{\raggedleft}p{1cm} instead of only p{1cm}. What is wrong with my environment?

Is there also a way to align the \cmidrule centered in the middle of the whole table? An extra table in a minipage-environment does not really work (the minipage is then right-aligned).

\documentclass[a4paper]{article}
\usepackage{geometry}
\geometry{paper=a4paper,inner=26mm,outer=26mm,top=30mm}
\usepackage{longtable}
\usepackage{array}
\usepackage{booktabs}
\newcolumntype{L}[1]{>{\raggedleft\hspace{0pt}}p{#1}}
\begin{document}
\begin{longtable}{lrrrp{1cm}}%{lrrrL{1cm}}
\caption{Fo}
\label{tab:ll}\\
\toprule
Nanana  &\multicolumn{1}{p{3cm}}{nononononon nii nuu Ononononono}&\multicolumn{1}{p{3cm}}{nononononon nunu nnu bobobobobob}&nun&\multicolumn{1}{p{3cm}}{nono non nonors nononno nunununun}\\\midrule
\multicolumn{5}{c}{nonono,\qquad nono=0.042\quad nununu=0.011}\\
\multicolumn{5}{c}{npnpnpnpnpnpnnununuu:\qquad 2.35}\\
\cmidrule(lr){2-4}
0   &6907   &6615   &3684   &79 \\
1   &96907  &96615  &93684  &179    \\
\bottomrule
\end{longtable}
\end{document}
2
  • Welcome to TeX.SE! Your write-up, I'm afraid, is a bit confusing. Are you trying the left- or right-align the contents of entire rows (which is what you write) or columns? Please clarify.
    – Mico
    Commented Jun 24, 2012 at 18:00
  • Sorry for the inconvenience. It is a bit difficult for me to explain the problem. The first row (with the words) should be left-aligned. The other rows (with the numbers) should be right-aligned (but the first column should be left-aligned in each case). But additionally, the gap between the numbers should not be so big -- especially for the last column. Due to the width of the last column in the first row (the words...) I get a large gap between e.g. "3684 &79".
    – Mia
    Commented Jun 24, 2012 at 19:48

1 Answer 1

2

The problem is well known and documented in the package array: if you have >{\raggedleft} in the last column either you use \tabularnewline for ending the row or say

>{\raggedleft\arraybackslash}p{3cm}

It's also wrong to specify p{1cm} in the table preamble, while using p{3cm} in the \multicolumn: use the same dimension in both places.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .