# How to make this table prettier?

Self-explanatory title. I'm new to LaTeX and this table looks pretty ugly.

\documentclass[letterpaper]{article}
\special{papersize=8.5in,11in}
\usepackage{indentfirst}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{amsmath}

\usepackage{gensymb}
\usepackage[margin=1in]{geometry}
\setlength{\parskip}{1em}

\begin{document}

\begin{table}
\centering
\begin{tabular}{|c|ccccc|}
\hline
&  $0$ & $\frac{\pi}{6}$      & $\frac{\pi}{4}$      & $\frac{\pi}{6}$
& $\frac{\pi}{2}$  \\
\hline
$\sin x$ & $0$  & $\frac{1}{2}$        & $\frac{\sqrt{2}}{2}$ &
$\frac{\sqrt{3}}{2}$ & $1$  \\
$\cos x$ & $1$  & $\frac{\sqrt{3}}{2}$ & $\frac{\sqrt{2}}{2}$ & $\frac{1}{2}$        & $0$  \\
$\tan x$ & $0$  & $\frac{\sqrt{3}}{3}$ & $1$                  & $\sqrt{3}$           &   \\
\hline
\end{tabular}
\end{table}

\end{document}


Thank you.

• Welcome to TeX.SE! How about \renewcommand{\arraystretch}{1.57}? I'd also like to encourage you to be a bit more specific, i.e. to tell us what you wish to achieve. Otherwise there is a danger that this question could be closed as "primarly opinion based". – user121799 Sep 26 '18 at 1:44
• The booktabs package (and documentation) has some strongly held opinions about making tables pretty. #1 is no vertical lines. But I do agree with marmot that it's not clear what you want to achieve. – Teepeemm Sep 26 '18 at 1:48
• It would also be helpful (for us casual readers) to include an image of the "ugly" table. – MrWhite Sep 26 '18 at 16:12
• Typo: the second $\frac{\pi}{6}$ in the heading should be $\frac{\pi}{3}$. So far, all the answers have reproduced this error faithfully! – TonyK Sep 26 '18 at 18:44
• This might be tangential, but looking at the answers I have this great urge to nicely ask for filling the gap in place for tan(pi/2). It almost looks like an erroneous omission. – luk32 Sep 26 '18 at 23:24

I'd keep it as simple as possible.

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amssymb}

\usepackage{booktabs}
\usepackage{array}
\usepackage{caption} % optional

\begin{document}

\begin{table}

\centering

\caption{Table of trigonometric functions for common angles}

$\setlength{\arraycolsep}{12pt} % for this particular table \begin{array}{@{} l *{5}{>{\displaystyle}c} @{}} \toprule & 0 & \frac{\pi}{6} & \frac{\pi}{4} & \frac{\pi}{6} & \frac{\pi}{2} \\ \midrule \sin x & 0 & \frac{1}{2} & \frac{\sqrt{2}}{2} & \frac{\sqrt{3}}{2} & 1 \\ \addlinespace \cos x & 1 & \frac{\sqrt{3}}{2} & \frac{\sqrt{2}}{2} & \frac{1}{2} & 0 \\ \addlinespace \tan x & 0 & \frac{\sqrt{3}}{3} & 1 & \sqrt{3} & \\ \bottomrule \end{array}$

\end{table}

\end{document}


I use array to simplify the input (no $ necessary except around the array). With \addlinespace we can easily separate the lines. With a larger value of \arraycolsep we better separate the columns for ease of reading in this particular case. my primary concern is to simplify your code. other is opinion based ... • instead tabular i would use array and than remove all $ in table code
• for more vertical space i would employ the makecell package, i.e. use its macro \gapedcells:
• note: mathtools load amsmath, so there is no need to load it again (loading packages more than once is not always innocuous...)

\documentclass[letterpaper]{article}
\usepackage[margin=1in]{geometry}
\usepackage{indentfirst}
\usepackage{mathtools}
\usepackage{amssymb}
%\usepackage{gensymb}   % <--- do you really need?
\usepackage{makecell}   % <--- new

\setlength{\parskip}{1em}

\begin{document}

$\setcellgapes{3pt} \makegapedcells \begin{array}{c|ccccc} & 0 & \frac{\pi}{6} & \frac{\pi}{4} & \frac{\pi}{6} & \frac{\pi}{2} \\ \hline \sin x & 0 & \frac{1}{2} & \frac{\sqrt{2}}{2} & \frac{\sqrt{3}}{2} & 1 \\ \cos x & 1 & \frac{\sqrt{3}}{2} & \frac{\sqrt{2}}{2} & \frac{1}{2} & 0 \\ \tan x & 0 & \frac{\sqrt{3}}{3} & 1 & \sqrt{3} & \infty \\ \end{array}$

\end{document}


• This is by far the best looking table IMHO. – TonyK Sep 26 '18 at 18:45
\documentclass[border=3pt]{standalone}
\usepackage{booktabs}
\usepackage{array}
\usepackage{amsmath}

\setlength\extrarowheight{2pt}

\def\getNum#1\relax{\gdef\num{#1}$\tfrac{1}{2}\sqrt{#1}$}

\def\getDenum#1\\{\gdef\denum{#1}$\tfrac{1}{2}\sqrt{#1}$&$\sqrt{\tfrac{\num}{\denum}}$\\}

\begin{document}

\begin{tabular}
{
>{$}c<{^\circ$}
>{\getNum}c
>{\getDenum}c
c
}
\toprule
\multicolumn{1}{c}{$\theta$}&
\multicolumn{1}{c}{$\sin\theta$}&
\multicolumn{1}{c}{$\cos\theta$}&
\multicolumn{1}{c}{$\tan\theta$}\\
\midrule
0&
0&
4\\
30&
1&
3\\
45&
2&
2\\
60&
3&
1\\
90&
4&
0\\
\bottomrule
\end{tabular}

\end{document}


1. Use \toprule and \bottomrule from booktabs at the beginning and end of your table
2. Remove rules among columns and rows except the first one
3. Use tabularx with type X column instead of tabular (it is better since you force columns with similar contents to be of equal size, at least in my opinion)
4. Stretch your array \renewcommand{\arraystretch}{1.5}
5. Use 'tab' to indent nested contents (this is to make debugging and revisions easier)

Code

\documentclass[letterpaper]{article}
\special{papersize=8.5in,11in}
\usepackage{indentfirst}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{amsmath}
\setlength{\parskip}{1em}
\usepackage{gensymb}
\usepackage[margin=1in]{geometry}

\usepackage{ragged2e}
\usepackage{tabularx}
\newcolumntype{C}{ >{ \arraybackslash \Centering } X }
\usepackage{booktabs}

\renewcommand{\arraystretch}{1.5}
\setlength{\parskip}{1em}

\begin{document}

\begin{table}

\centering

\begin{tabularx}{0.35\textwidth}{c| *{5}{C}}
\toprule
&  $0$ & $\frac{\pi}{6}$      & $\frac{\pi}{4}$      & $\frac{\pi}{6}$
& $\frac{\pi}{2}$
\\
\hline
$\sin x$ & $0$  & $\frac{1}{2}$        & $\frac{\sqrt{2}}{2}$ &
$\frac{\sqrt{3}}{2}$ & $1$
\\
$\cos x$ & $1$  & $\frac{\sqrt{3}}{2}$ & $\frac{\sqrt{2}}{2}$ & $\frac{1}{2}$        & $0$
\\
$\tan x$ & $0$  & $\frac{\sqrt{3}}{3}$ & $1$                  & $\sqrt{3}$           &
\\
\bottomrule
\end{tabularx}

\end{table}

\end{document}


A workaround in tabu, an extension of tabularx; the most important thing to better presentations for fractions in math is to preserve the size of the numbers for this reason you must use \dfrac instead \frac; in the MWE some colors and rules modifications with tabu.

RESULT:

MWE:

% arara: pdflatex: {synctex: yes, action: nonstopmode}
\documentclass[letterpaper]{article}
\special{papersize=8.5in,11in}
\usepackage{indentfirst}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{gensymb}
\usepackage[margin=1in]{geometry}
\setlength{\parskip}{1em}
\usepackage[table]{xcolor}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{tabu}

\begin{document}

\begin{table}[!h]
\centering
\tabulinesep=5pt
\tabulinestyle{1pt,blue}
\begin{tabu} to 0.5\linewidth {|X[c]|X[c]|[0.75pt]X[c]|[0.75pt]X[c]|[0.75pt]X[c]|[0.75pt]X[c]|}
\rowfont{\leavevmode\color{white}}
\multicolumn{1}{c|}{}
&\cellcolor{blue!30}$0$
&\cellcolor{blue!40}$\dfrac{\pi}{6}$
&\cellcolor{blue!50}$\dfrac{\pi}{4}$
&\cellcolor{blue!60}$\dfrac{\pi}{6}$
&\multicolumn{1}{c|}{\cellcolor{blue!70}$\dfrac{\pi}{2}$}
\\ \tabucline -

%row2
$\sin x$
&$0$
&$\dfrac{1}{2}$
&$\dfrac{\sqrt{2}}{2}$
&$\dfrac{\sqrt{3}}{2}$
&$1$
\\[-0.5pt] \tabucline [0.5pt on 3pt blue] -

%row3
$\cos x$
&$1$
&$\dfrac{\sqrt{3}}{2}$
&$\dfrac{\sqrt{2}}{2}$
&$\dfrac{1}{2}$
&$0$
\\[-0.5pt] \tabucline [0.5pt on 3pt blue] -

%row4
$\tan x$
& $0$
& $\dfrac{\sqrt{3}}{3}$
& $1$
& $\sqrt{3}$
&
\\ \tabucline -

\end{tabu}
\end{table}

\end{document}


In my opinion, cals, the packages bm and cmbright and some light colours, are improvements:

\documentclass[a4paper, 11pt]{article}
\usepackage{bm, cmbright, cals}
\usepackage[dvipsnames]{xcolor}
\renewcommand{\sfdefault}{cmbr}
%\everymath{\displaystyle}                                  % Nicest without displaystyle?

\begin{document}
\begin{calstable}[c]
\colwidths{{56pt}{33pt}{33pt}{33pt}{33pt}{33pt}} % 6 columns
\makeatletter
\def\cals@framers@width{0.4pt}
\def\cals@framecs@width{0.4pt}
\cals@setcellprevdepth{Al}
\def\cals@cs@width{0.2pt}
\def\cals@rs@width{0.2pt}
\def\cals@bgcolor{}

\def\gray{\ifx\cals@bgcolor\empty
\def\cals@bgcolor{gray!15}
\else \def\cals@bgcolor{} \fi}

\def\green{\ifx\cals@bgcolor\empty
\def\cals@bgcolor{green!15}
\else \def\cals@bgcolor{} \fi}

\def\blue{\ifx\cals@bgcolor\empty
\def\cals@bgcolor{blue!15}
\else \def\cals@bgcolor{} \fi}

\def\black{\ifx\cals@bgcolor\empty
\def\cals@bgcolor{black}
\else \def\cals@bgcolor{} \fi}

% R1
\brow
\green\alignC\cell{\vfil $0$}
\alignC\cell{\vfil $\frac{\pi}{6}$}
\alignC\cell{\vfil $\frac{\pi}{4}$}
\alignC\cell{\vfil $\frac{\pi}{3}$}
\alignC\cell{\vfil $\frac{\pi}{2}$}\green
\ht\cals@current@row=33pt
\erow
% R3
\brow
\blue\alignC\cell{\vfil \textbf{sin}($\bm{\theta}$)}\blue
\alignC\cell{\vfil $0$}
\alignC\cell{\vfil $\frac{1}{2}$}
\alignC\cell{\vfil $\frac{\sqrt 2}{2}$}
\alignC\cell{\vfil $\frac{\sqrt 3}{2}$}
\alignC\cell{\vfil $1$}
\ht\cals@current@row=33pt
\erow
% R4
\brow
\blue\alignC\cell{\vfil \textbf{cos}($\bm{\theta}$)}\blue
\alignC\cell{\vfil $1$}
\alignC\cell{\vfil $\frac{\sqrt 3}{2}$}
\alignC\cell{\vfil $\frac{\sqrt 2}{2}$}
\alignC\cell{\vfil $\frac{1}{2}$}
\alignC\cell{\vfil $0$}
\ht\cals@current@row=33pt
\erow
% R5
\brow
\blue\alignC\cell{\vfil \textbf{tan}($\bm{\theta}$)}\blue
\alignC\cell{\vfil $0$}
\alignC\cell{\vfil $\frac{\sqrt 3}{3}$}
\alignC\cell{\vfil $1$}
\alignC\cell{\vfil $\sqrt 3$}
\black\alignC\cell{}\black
\ht\cals@current@row=33pt
\erow\makeatother
\end{calstable}\par

\end{document}