2

I'm trying to recreate the attached table (left one). I managed to to create the right one with following code:

\begin{tabular}{c|cccc|c}
    \hline
    \backslashbox{$X_i$}{$Y_i$} &  $y_i$ & $y_2$ & $\ldots$ & $y_s$ & $\Sigma$\\
    \hline
    $x_i$ & $n_{11}$ & $n_{12}$ & $\ldots$ & $n_{1s}$ & $n_{1\cdot}$\\
    $x_2$ & $n_{21}$ & $n_{22}$ & $\ldots$ & $n_{2s}$ & $n_{2\cdot}$\\
    $\vdots$ & $\vdots$ & $\vdots$ & $\ddots$ & $\vdots$ & $\ddots$\\
    $x_r$ & $n_{r1}$ & $n_{r2}$ & $\ldots$ & $n_{rs}$ & $n_{r\cdot}$\\
    \hline
    $\Sigma$ & $n_{\cdot1}$ & $n_{\cdot2}$ & $\ldots$ & $n_{\cdot s}$ & $n$\\
    \hline
\end{tabular}

How can I make my vertical lines not cross horizontal lines?

enter image description here

  • 1
    Please, be so kind and convert your code sneped to full smal document beginning wit \documentclass{...} used relevant packages and ending with \end{document}. It seems that instead \hlines you sould use rules from booktabs package. For test this idea, I need complete document ... – Zarko Jan 17 '17 at 22:29
  • Please state how or where the macro \backslashbox is defined. – Mico Jan 18 '17 at 0:23
1

One way to do this would be to use \midrule from the booktabs package.

Code:

\documentclass{article}
\usepackage{slashbox}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{c|cccc|c}
    \midrule
    \backslashbox{$X_i$}{$Y_i$} &  $y_i$ & $y_2$ & $\ldots$ & $y_s$ & $\Sigma$\\
    \midrule
    $x_i$ & $n_{11}$ & $n_{12}$ & $\ldots$ & $n_{1s}$ & $n_{1\cdot}$\\
    $x_2$ & $n_{21}$ & $n_{22}$ & $\ldots$ & $n_{2s}$ & $n_{2\cdot}$\\
    $\vdots$ & $\vdots$ & $\vdots$ & $\ddots$ & $\vdots$ & $\ddots$\\
    $x_r$ & $n_{r1}$ & $n_{r2}$ & $\ldots$ & $n_{rs}$ & $n_{r\cdot}$\\
    \midrule
    $\Sigma$ & $n_{\cdot1}$ & $n_{\cdot2}$ & $\ldots$ & $n_{\cdot s}$ & $n$\\
    \midrule
\end{tabular}
\end{document}

Yields:

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.