2

I am currently working on my master thesis and my tables which are used as a type of matrix simply look awful. How can i make them look much better?

\begin{table}[H]
    \centering
    \begin{tabular}{c|c|c|c|c}
        &\textgreater& =+ & =- & \textless \\
        \hline
        \textgreater & 1 & 0 & 0 & -1 \\
        \hline
        =+ & 0 & 1 & 0 & 0 \\
        \hline
        =- & 0 & 0 & 1 & 0 \\
        \hline
        \textless & -1 & 0 & 0 & 1 \\
        \hline
    \end{tabular}
\end{table}

enter image description here

JavaCake
  • 481
  • The width of the cells are not consistent and the chars are differing in size, basically i want this to look better. My other solution is to make it in Photoshop, but id prefer to do it in LaTeX. – JavaCake Sep 13 '14 at 16:24

3 Answers3

6

While beauty is in the eye of the beerholder, here is one option:

enter image description here

\documentclass{article}
\usepackage{array}
\newcolumntype{C}[1]{>{\centering\arraybackslash$}p{#1}<{$}}
\begin{document}

\[
  \begin{array}{c| *{4}{C{2em}}}
    & \multicolumn{1}{c}{>} & =\joinrel+ & =\joinrel- & \multicolumn{1}{c}{<} \\
    \hline
    > & \phantom{-}1 & 0 & 0 & -1 \\
    =\joinrel+ & \phantom{-}0 & 1 & 0 & \phantom{-}0 \\
    =\joinrel- & \phantom{-}0 & 0 & 1 & \phantom{-}0 \\
    < & -1 & 0 & 0 & \phantom{-}1
  \end{array}
\]

\end{document}
Werner
  • 603,163
6

Here is somme more air, and no \phantom, with the siunitx package. Some colour, and different widths horizontal and vertical rule:

\documentclass{article}
\usepackage{array}
\usepackage[x11names]{xcolor}
\usepackage{colortbl}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{makecell}
\renewcommand\theadfont{\color{LightSteelBlue3}\mathversion{bold}}
\setcellgapes{5pt}
\makegapedcells
\begin{document}

\[\setlength\arraycolsep{1em}\arrayrulecolor{Tomato3}\setlength\arrayrulewidth{0.8pt}
  \begin{array}{ @{}>{\color{LightSteelBlue3}\mathversion{bold}}c@{\quad}!{\color{Tomato3}\vrule width 1.2pt}*{4}{S[table-format = 1.0]}}
   & {\thead{>}} & {\thead{=\joinrel+}} & {\thead{=\joinrel-}} & {\thead{<}} \\[-1ex]
    \hline
    > & -1 & 0 & 0 & -1 \\
    =\joinrel+ & 0 & 1 & 0 & 0 \\
    =\joinrel- & 0 & 0 & 1 & 0 \\
    < & -1 & 0 & 0 & 1 \\[-2ex]
 &
  \end{array}
\]

\end{document} 

enter image description here

Bernard
  • 271,350
  • When i include siunitx i get some conflict with sistyle apparently: Package 'sistyle' incompatible – JavaCake Sep 14 '14 at 07:00
  • @JavaCake: I never used sistyle. As far as I know, it is no more developed and is superseded by siunitx. – Bernard Sep 14 '14 at 09:31
2

Usine memoir class you can also do as shown below

\documentclass{memoir}
\begin{document}
\begin{table}[H]
      \begin{tabular*}{0.95\textwidth}{@{\extracolsep{\fill}}l|rrrr}
    \toprule
           &  \textgreater& \textbf{ =+}  & \textbf{=-} & \textbf{\textless} \\
     \midrule
       \textgreater & \textbf {1} & \textbf{0} & \textbf{0} & \textbf{ -1}\\
       =+ &\textbf{ 0} &\textbf{1} & \textbf{0} & \textbf{0} \\
       =- &\textbf{ 0} & \textbf{0} & \textbf{1}&\textbf{ 0} \\
      \textless &\textbf{ -1} & \textbf{0} &\textbf{0} &\textbf{1}\\
        \bottomrule
    \end{tabular*}
  \end{table}
\end{document}

output:

beautytbl

egreg
  • 1,121,712
murugan
  • 1,669
  • 4
    The - symbols -- in the header row and column as well as in the body of the table -- really ought to be rendered as typographic minus signs rather than as the much shorter typographic dash (aka hyphen) characters. Also, if you're going to use the macros of the booktabs package, don't use vertical lines in the table; conversely, if you really must use vertical bars, don't use the macros of the booktabs package. Incidentally, why did you encase the contents of every single cell in a \textbf "wrapper"? – Mico Sep 13 '14 at 18:09