4

I have this table in hands and I want to make it more appealing.

Horrible Table

I have a trouble with the \ in the first cell of the table, and all solutions that I found here in tex.stackexchange are not beautiful nor inspire me for other solutions.

What do you recommend me to do here, to avoid splitting the first cell in two diagonal parts? Or please present me some creative idea with the \ that divides the cell...

Thanks in advance.

Leafar
  • 155

2 Answers2

9

I propose one of these:

    \documentclass[11pt,pdftex, a4paper]{article}
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage{lmodern}
    \usepackage{amsmath, diagbox, hhline, booktabs}
    \usepackage[table, x11names, svgnames]{xcolor}

    \begin{document}

        \begin{tabular}{|c|*{3}{>{$}c<{$}|}}
          \hline
          \diagbox[linewidth=0.2pt, width=\dimexpr \textwidth/10+2\tabcolsep\relax, height=0.6cm]{$\enspace\boldsymbol \alpha $}{$\;\boldsymbol \beta $}
   & -1 & 0 & 1 \\
          \hline
          $ -1 $ & 0& -1 & -2\\
          \hline
          $ 0 $ & 1 & 0 &-1 \\
          \hline
           $ 1 $ & 2 & 1 & 0 \\
          \hline
        \end{tabular}
    \bigskip

     \begin{tabular}{!{\color{IndianRed3} \vrule}c !{\color{IndianRed3}\vrule\,\vrule}*{2}{>{$}c<{$}!{\color{Lavender}\vrule}} >{$}c<{$}!{\color{IndianRed3}\vrule}}%
     \arrayrulecolor{IndianRed3}
              \hhline{-||---}
          \diagbox[linecolor=Lavender, linewidth=0.3pt, width=\dimexpr \textwidth/10+2\tabcolsep\relax, height=0.6cm]{$ \enspace\boldsymbol \alpha $}{$\;\boldsymbol \beta $}
   & -1 & 0 & 1 \\
          \hhline{=::===}
          $ -1 $ & 0& -1 & -2\\
 \hhline{|>{\arrayrulecolor{Lavender}}->{\arrayrulecolor{IndianRed3}}||>{\arrayrulecolor{Lavender}}--->{\arrayrulecolor{IndianRed3}}|}
          $ 0 $ & 1 & 0 &-1 \\
          \hhline{|>{\arrayrulecolor{Lavender}}-||--->{\arrayrulecolor{IndianRed3}}|}
           $ 1 $ & 2 & 1 & 0 \\
     \arrayrulecolor{IndianRed3}
          \hhline{-||---}
        \end{tabular}

    \bigskip

 $ \setlength\extrarowheight{3pt} \begin{array}{c @{\,}>{\columncolor{Thistle3}[0pt][6pt]}r!{\mkern 2mu}|*{3}{c|}}
         \multicolumn{2}{c}{ } & \multicolumn{3}{c}{\boldsymbol \beta }\\
        \rowcolor {LightPink2!50}\multicolumn{1}{c}{\cellcolor{white}} &\multicolumn{1}{c!{\mkern4mu}}{\cellcolor{Plum4}} & \multicolumn{1}{c}{-1} & \multicolumn{1}{c}{0} & \multicolumn{1}{c}{1} \\
        \addlinespace[0.5ex]
        \cline{3-5}
        & -1 & 0& -1 & -2\\
        \cline{3-5}
         \boldsymbol \alpha & 0 & 1 & 0 &-1 \\
        \cline{3-5}
             & 1 & 2 & 1 & 0 \\
        \cline{3-5}
        \end{array} $
   \end{document}

enter image description here

Bernard
  • 271,350
  • Thanks for answering. The third one seems to be the best one, it is less ''cagey''. – Leafar Aug 01 '16 at 21:32
  • LOL, I remarked that the alpha and beta are switched in the last table, I suddently was afraid that I couldn't subtract anymore and should return to elementary (because the entry of the table is the result of $\alpha - \beta$) – Leafar Aug 01 '16 at 22:16
  • It's the result of copying-pasting at the end of day… I'll fix that. – Bernard Aug 01 '16 at 22:18
  • @Leafar: I've updated, and slightly improved the first two solutions. – Bernard Aug 01 '16 at 23:05
  • +1 for using the newer diagbox package rather than the older slashbox package. :-) – Mico Aug 02 '16 at 01:13
3

You could try something like this.

I think you need to get rid of the cagey appearance of your table and I'm not sure the diagonally split cell is the way to go.

So I offer you this, although you might want to consider using a different alignment so that the numerals are aligned with each other, but you went with centring in your example and some people prefer that. But please, please note that a hyphen (-) is not a minus sign. Your -s need to be in math mode.

\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{array}

\begin{document}

\begin{tabular}{*{4}{>{\arraybackslash$}c<{$}}}

  & \multicolumn{3}{c}{$\beta$} \\

  \cmidrule(lr){2-4}

  \alpha & -1 & 0 & 1 \\

  \midrule

  -1 & 0 & -1 & -2 \\

  0 & 1 & 0 & -1 \\

  1 & 2 & 1 & 0

\end{tabular}

\end{document}

enter image description here

Au101
  • 10,278
  • Thank you for answering. I considered to make one table like yours, but for my purpose it is very important to ''separate'' the entries of the tables from the values of $\alpha$ and $\beta$. Doing the same for $\alpha$ as you did for $\beta$ it's something that I thought but after doing the table it remained horrible. – Leafar Aug 01 '16 at 21:36