2
\begin{longtable}{|cc|c|c|c|c|c|}
\caption{Result table}
\cline{3-7}
\multicolumn{2}{c}{}&\multicolumn{5}{|c|}{Name}
\endfirsthead
\multicolumn{2}{c}{}&\multicolumn{1}{|c|}{Line 3}&M&N1&T&N2\\
\hline
Data&AW0&3,05,185&44,064&42,217&23,735&42,578\\
\cline{2-7}
&AW2&4,29,520&60,437&59,258&35,445&59,619\\
\cline{2-7}
&AW3&4,60,671&64,603&63,519&38,333&63,880\\
\hline

\end{longtable}

enter image description here

Here I expect line to start from column number 3 and end at 7 (Last one). But it is starting from 1st and going till 5. Can anybody tell me what I am doing wrong here.

1
  • 3
    As always on this site, please provide a full minimal example instead of a sniplet, that way it is a lot easier for others to test your code with out having to guess. Secondly, don't ignore errors, this sniplet gives an error, which is resolved if you use \coaption{...}\\
    – daleif
    Commented May 3, 2019 at 10:06

2 Answers 2

4

First, of you will make it a lot easier for others to help if you provide a full minimal example instead of a sniplet, then we do not have to guess the rest.

Secondly, don't just ignore compilation errors. I get the following error

! Misplaced \omit.
\@cline #1-#2\@nil ->\omit 
                           \@multicnt #1\advance \@multispan \m@ne \ifnum \@...
l.8 \cline{3-7}

Which can be a bit hard to decipher, thus it is a good idea to cite this error in your question.

This error is due to how \caption works in longtable, it is basically a hidden \multicolumn, thus that line has to be ended with \\

And then your document compiles just fine

\documentclass{article}
\usepackage{longtable}
\begin{document}

\begin{longtable}{|cc|c|c|c|c|c|}
\caption{Result table}\\
\cline{3-7}
\multicolumn{2}{c}{}&\multicolumn{5}{|c|}{Name}
\endfirsthead
\multicolumn{2}{c}{}&\multicolumn{1}{|c|}{Line 3}&M&N1&T&N2\\
\hline
Data&AW0&3,05,185&44,064&42,217&23,735&42,578\\
\cline{2-7}
&AW2&4,29,520&60,437&59,258&35,445&59,619\\
\cline{2-7}
&AW3&4,60,671&64,603&63,519&38,333&63,880\\
\hline

\end{longtable}


\end{document}

Though, note that nowadays people does not really use vertical lines in tables any more as it actually make it harder to read than with out them.

1
  • Thanks a lot, it worked.
    – sameerk
    Commented May 3, 2019 at 12:14
0

I had a similar problem. I added \\ at the end of both \label and \caption and it worked! Both were above the first cline.

\begin{longtable}[t]{c l | l l l | l l c |}
\label{tab:thelabel}\\
\caption{The caption goes here}\\
\cline{3-8}
& & \multicolumn{3}{c|}{One} & \multicolumn{3}{c|}{Two}\\
1
  • 1
    That is the wrong place to add the label. It is \caption that provides the number that \label can refer to, not longtable (this is a very common error for new latex users). You should use \caption{The caption goes here}\label{tab:thelabel}\\
    – daleif
    Commented Dec 10, 2019 at 10:54

You must log in to answer this question.

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