2

I want to make this table: enter image description here

Whereas, I get this one: enter image description here Any suggestions for the code I wrote below?

\begin{center}
\begin{tabular}{c|cc|c|}
& $A$ & NOT $A$ & SUM\\ \hline
$B$ & $P(A$ AND$\,B)$ & $P($NOT $A$ AND$\,B)$ & $P(B)$\\ 
NOT $B$ &$P(A\,$NOT$\,B)$ &$P($NOT $A\,$AND NOT$\,B)$ & $P($NOT $B)$ \\ \hline
& $P(A)$ & $P($NOT $A)$& $1$\\ \hline
\end{tabular}
\end{center}
  • Welcome to TeX.SE! Can the text font not be the same? – manooooh Aug 30 '18 at 1:08
5

With no additional packages (I am assuming that Comic Sans is not your dream):

\documentclass{article}


\begin{document}

\begin{center}
\begin{tabular}{c|cc|c|}
\multicolumn{1}{c}{}& $A$ &\multicolumn{1}{c}{ NOT $A$} &\multicolumn{1}{c}{ SUM}\\ 
%\hline
\cline{2-4}
$B$ & $P(A$ AND$\,B)$ & $P($NOT $A$ AND$\,B)$ & $P(B)$\\ 
NOT $B$ &$P(A\,$NOT$\,B)$ &$P($NOT $A\,$AND NOT$\,B)$ & $P($NOT $B)$ \\ 
%\hline
\cline{2-4}
& $P(A)$ & $P($NOT $A)$& $1$\\ 
%\hline
\cline{2-4}
\end{tabular}
\end{center}

\end{document}

enter image description here

|improve this answer|||||
3

This is easy with blkarray:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathtools, blkarray}

\begin{document} 

\[ \everymath{\displaystyle}\setlength{\BAextrarowheight}{2pt}
\begin{blockarray}{cccc}
    & A & \text{NOT }A & \text{SUM} \\
    \BAhhline{~---}
    \begin{block}{c|cc|c|}
    B & P(A\text{ AND}B) & P(\text{NOT }A\text{ AND }B) & P(B)\\
    \text{NOT }B &P(A\text{ NOT }B) &P(\text{NOT }A\text{ AND NOT }B) & P(\text{NOT }B) \\
    \BAhhline{~|---|}
    & P(A) & P(\text{NOT }A)& 1\\
    \BAhhline{~---}
    \end{block}
\end{blockarray} \]

\end{document} 

enter image description here

|improve this answer|||||
  • please use \text{} for SUM. – corvus_192 Aug 30 '18 at 8:43
  • @corvus_192: Oh! yes, I forgot this cell. It's fixed. Thanks for pointing it! – Bernard Aug 30 '18 at 9:08
2

enter image description here

Use \multicolumn command to suppress vertical ruling of specific cells. If the table width is not as you want, try to modify the width provided in {\textwidth}

\documentclass{article}
\usepackage{amsmath}
\renewcommand{\arraystretch}{1.7}
\usepackage{ragged2e}
\usepackage{tabularx}
\newcolumntype{C}{ >{ \arraybackslash \Centering } X }
\usepackage{booktabs}
\usepackage{makecell}

\begin{document}


\noindent
\begin{table*}

    \centering
    \begin{tabularx}{\textwidth}{>{\hsize=0.3\hsize}C |>{\hsize=1.5\hsize} C>{\hsize=1.5\hsize}C| >{\hsize=0.7\hsize}C|}
        \multicolumn{1}{c}{} & \multicolumn{1}{c}{$A$} &  \multicolumn{1}{c}{$A^{'}$} & \multicolumn{1}{c}{SUM}
    \\
    \Xcline{2-4}{0.2mm}
        $B$ & $P(A \text{ AND } B)$ & $P(\text{NOT } A \text{ AND } B)$ & $P(B)$
    \\ 
        $B^{'}$ & $P(A \text{ AND NOT } B)$ & $P(\text{NOT } A \text{ AND NOT} B)$ & $P($NOT $B)$
    \\
    \Xcline{2-4}{0.2mm}
        & $P(A)$ & $P($NOT $A)$& $1$
    \\
    \Xcline{2-4}{0.2mm}
    \end{tabularx}

\end{table*}


\end{document}
|improve this answer|||||

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.