2

I want to edit the table to the left below, into the second screenshot to the right (the three tiny short lines indicate that this line should not be there, the 'Test' below should not be there too).

Thanks in advance!

enter image description here enter image description here

\documentclass[border=1cm]{standalone}

\begin{document}

\begin{tabular}{|c||c|c|c|c|c|}\hline
     \textbf{Test} & 1 & 2 & 3 & 4 & 5  \\ \hline 
     {\textbf{U}} \\ \hline
     {a} & 1 & 0 & 0 & 0 & 0 \\ \hline
     {b} & 0 & 1 & 0 & 0 & 0 \\ \hline
     {c} & 0 & 0 & 1 & 0 & 0 \\ \hline
     {d} & 0 & 0 & 0 & 1 & 0 \\ \hline
     {\textbf{W}}\\ \hline
     {e} & \textbf{1} & 0 & 0 & 0 & 0  \\ \hline
     {f} & 0 & \textbf{1} & \textbf{1} & \textbf{1} & 0 \\ \hline
     {g} & 0 & 1 & 1 & 0 & \textbf{1} \\ \hline

 \end{tabular}  

 \end{document}

2 Answers 2

4

Like this? Using \cline and some multicolumns.

d4rtyTabular

\documentclass[border=1cm]{standalone}

\begin{document}

\begin{tabular}{|c||c|c|c|c|c|}\hline
    & \multicolumn{5}{c|}{Test}\\\cline{2-6}
    \textbf{Test} & 1 & 2 & 3 & 4 & 5  \\ \hline 
    \textbf{U}&\multicolumn{5}{c|}{} \\ \hline
    a & 1 & 0 & 0 & 0 & 0 \\ \hline
    b & 0 & 1 & 0 & 0 & 0 \\ \hline
    c & 0 & 0 & 1 & 0 & 0 \\ \hline
    d & 0 & 0 & 0 & 1 & 0 \\ \hline
    \textbf{W}&\multicolumn{5}{c|}{}\\ \hline
    e & \textbf{1} & 0 & 0 & 0 & 0  \\ \hline
    f & 0 & \textbf{1} & \textbf{1} & \textbf{1} & 0 \\ \hline
    g & 0 & 1 & 1 & 0 & \textbf{1} \\ \hline

\end{tabular}  

\end{document}
2
  • Yes, exactly what I was looking for! Thanks
    – d4rty
    Nov 10, 2015 at 14:55
  • @Mico the ones i just deleted? Or do you mean others?
    – Johannes_B
    Nov 10, 2015 at 14:57
2

You can also do by using booktabs. This is the easiest way to present the data in tables

\documentclass[border=1cm]{standalone}

\usepackage{booktabs}

\begin{document}

\begin{tabular}{ccccccc}

    \toprule
    \textbf{Test} & & 1 & 2 & 3 & 4 & 5  \\ \midrule
     {\textbf{U}}& & & & & \\ \midrule
    & {a} & 1 & 0 & 0 & 0 & 0 \\ \midrule
    & {b} & 0 & 1 & 0 & 0 & 0 \\ \midrule
    & {c} & 0 & 0 & 1 & 0 & 0 \\ \midrule
    & {d} & 0 & 0 & 0 & 1 & 0 \\ \midrule
    {\textbf{W}}& & & & & \\ \midrule
     &{e} & \textbf{1} & 0 & 0 & 0 & 0  \\ \midrule
    & {f} & 0 & \textbf{1} & \textbf{1} & \textbf{1} & 0 \\ \midrule
     &{g} & 0 & 1 & 1 & 0 & \textbf{1} \\ \bottomrule
 \end{tabular}  

 \end{document}

booktabstbl

1
  • 1
    A couple of comments: (i) I think the word "Test" is supposed to be in the top row, spanning columns 2 thru 6. (ii) Since you're using the superior booktabs package, you may also want to show just how much better the table can look if the interior horizontal lines are omitted along with all those vertical lines.
    – Mico
    Nov 10, 2015 at 17:46

You must log in to answer this question.

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