I am trying to draw a horizontal line for cells 2 to 3 and then for cell 5 in a table using \\ \cline{2-3,5}. But it does not work for me. Can anyone tell me how to accomplish this in LaTeX tabular environment.

\multicolumn{2}{|c|}{Traffic} & \multicolumn{2}{|c|}{Training} & \multicolumn{2}{|c|}{Test}\\
\multicolumn{2}{|c|}{Normal} & \multicolumn{2}{|c|}{67343} & \multicolumn{2}{|c|}{9711} \\
\multicolumn{1}{|c|}{\multirow{4}{*}{Anomaly}} & \multicolumn{1}{|c|}{DoS} & 45927 & \multicolumn{1}{|c|}{\multirow{4}{*}{52000}} & 7458 & \multicolumn{1}{|c|}{\multirow{4}{*}{10000}}\\  
\multicolumn{1}{|c|}{} & U2R & 52 & \multicolumn{1}{|c|}{} & 67 & \multicolumn{1}{|c|}{}\\ 
\multicolumn{1}{|c|}{} & R2L & 995 & \multicolumn{1}{|c|}{} & 2887 & \multicolumn{1}{|c|}{}\\ 
\multicolumn{1}{|c|}{} & Probe & 11656 & \multicolumn{1}{|c|}{}& 2421 &\multicolumn{1}{|c|}{} \\ 
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – LaRiFaRi Jul 24 '15 at 6:35
  • 1
    Are you using a tabularx? If not (or if not necessary for your question), delete this tag from your question. Please show us, where you have found that command with comma in it. Never seen it but I do not want to say, it does not exist for some package. the normal approach in my eyes would be to do \\\cline{2-3}\cline{5-5} – LaRiFaRi Jul 24 '15 at 6:38
  • Thanks @LaRiFaRi . \cline{2-3}\cline{5-5} worked. I just intuitively put that which did not work. – user976754 Jul 24 '15 at 6:47

The command you are using does not support a comma separated list of parameters. It should be \\\cline{2-3}\cline{5-5} instead.

Below a recommendation on how to write the table for better readability and less coding. It also shows how to use the single column line but here with booktabs.

% arara: pdflatex


    Traffic & Training & Test\\
    Normal & $67343$ & $9711$ \\
    Anomaly \specialcell{l}{DoS\\U2R\\R2L\\Probe} & \specialcell{S[table-format=5.0]}{45927\\52\\995\\11656}  \num{52000} & \specialcell{S[table-format=4.0]}{7458\\67\\2887\\2421}  \num{10000} \\

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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