2

Okay, so I'm trying to make this sort of a table:

----------------------------
|                  A       |
|     &       true   false |
|           |--------------|
| B | true  |  1       1   |
|   | false |  2       3   |
|--------------------------|

and this is my code.

\begin{tabular}{|cccc|}
\hline
\multicolumn{2}{c}{\multirow{2}{*}{\&}} & & A
 & & true & false
\multirow{2}{*}{B} & false & 0 & 1 \\
 & true & 2 & 3 \\
\hline
\end{tabular}

Idk what I did wrong tbh. I'm finding this multirow, multicolumn stuff a little confusing...

5

Like this:

enter image description here

\documentclass{article}
\usepackage{multirow}

\begin{document}
\begin{tabular}{cc|cc}
            &           &   \multicolumn{2}{c}{A}   \\
\multicolumn{2}{c|}{\&} &   true    &   false       \\
    \hline
\multirow{2}{*}{B}      &   true    &   1   &    1  \\
                        &   false   &   2   &   3   
\end{tabular}
\end{document}

or this:

enter image description here

\documentclass{article}
\usepackage{multirow}

\begin{document}
\begin{tabular}{cc|cc}
\multicolumn{2}{c}{}    &   \multicolumn{2}{c}{A}   \\
\multicolumn{2}{c|}{\&} &   true    &   false       \\
    \hline
\multirow{2}{*}{B}      &   true    &   1   &   1   \\
            &   false   &   2       &   3           \\
\end{tabular}
\end{document}

or this?

enter image description here

\documentclass{article}
\usepackage{multirow}

\begin{document}
\begin{tabular}{|cc|cc|}
    \hline
\multicolumn{2}{|c|}{}  &   \multicolumn{2}{c|}{A}  \\
\multicolumn{2}{|c|}{\&}&   true    &   false       \\
    \hline
\multirow{2}{*}{B}      &   true    &   1   &   1   \\
            &   false   &   2       &   3           \\
    \hline
\end{tabular}
\end{document}

or finally (as described in your comment below):

enter image description here

\documentclass{article}
\usepackage{multirow}

\begin{document}
\begin{tabular}{|c|c|cc|}
    \hline
\multicolumn{2}{|c|}{}  &   \multicolumn{2}{c|}{A}  \\
    \cline{3-4}
\multicolumn{2}{|c|}{\&}&   true    &   false       \\
    \hline
\multirow{2}{*}{B}      &   true    &   1   &   1   \\
            &   false   &   2       &   3           \\
    \hline
\end{tabular}
\end{document}

to my taste, I would choose the first example ...

3
  • That last one is actually pretty nice, now that I think of it. – Osama Kawish Jun 18 '17 at 17:56
  • Tbh, I was going for something a bit more complicated and only wanted a box around the numbers, a line under the A, and a line next to the B as I showed. The entire table should also be boxed. – Osama Kawish Jun 18 '17 at 17:58
  • @OsamaKawish, I add one more example .... (sorry, your sketch was not very clear to me :-( ). – Zarko Jun 18 '17 at 18:55

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.