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.

  • 1
    Please, be so kind and show as, what you try so far. Help us that we can help you! By the way, see, if solution offered by package makecell fit your expectation. – Zarko Aug 1 '16 at 19:31
  • Or maybe this entry help you: <tex.stackexchange.com/questions/89745/…> – SeRe Aug 1 '16 at 19:33
  • perhaps it's just the small example, but do you need a table at all? it just seems to be α − β – David Carlisle Aug 1 '16 at 20:24
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

  • Thanks for answering. The third one seems to be the best one, it is less ''cagey''. – Leafar Aug 1 '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 1 '16 at 22:16
  • It's the result of copying-pasting at the end of day… I'll fix that. – Bernard Aug 1 '16 at 22:18
  • @Leafar: I've updated, and slightly improved the first two solutions. – Bernard Aug 1 '16 at 23:05
  • +1 for using the newer diagbox package rather than the older slashbox package. :-) – Mico Aug 2 '16 at 1: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

  • 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 1 '16 at 21:36

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.