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

1
  • 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, 2014 at 16:24

3 Answers 3

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}
6
  • You may have better off right justifying the first and last columns. Sep 13, 2014 at 16:35
  • +1 for beerholder (and the technical merits of the answer, of course). Sep 13, 2014 at 16:44
  • It's easier to use \llap or \rlap to align the columns, in my opinion.
    – 1010011010
    Sep 13, 2014 at 17:18
  • One last thing, how do i make lines in between all the cells, except the math signs on the outside?
    – JavaCake
    Sep 13, 2014 at 17:47
  • I suggest adding a little more air between the rows.
    – Sveinung
    Sep 13, 2014 at 17:51
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

2
  • When i include siunitx i get some conflict with sistyle apparently: Package 'sistyle' incompatible
    – JavaCake
    Sep 14, 2014 at 7:00
  • @JavaCake: I never used sistyle. As far as I know, it is no more developed and is superseded by siunitx.
    – Bernard
    Sep 14, 2014 at 9: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

1
  • 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, 2014 at 18:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .