1

MWE:

\documentclass{article}
\usepackage[a4paper,top=0.7in,bottom=0.4in,left=0.5in,right=0.5in,headheight=14.5pt]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[misc]{ifsym}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{amssymb}
\begin{document}
    \begin{tabular}{|c|c|c|c|c|c|}
        \hline
        $\theta$  & $0$         & $30$                  & $45$                  & $60$                  & $90$        \\ \hline
        $\sin$    & $0$         & $\dfrac{1}{2}$        & $\dfrac{1}{\sqrt{2}}$ & $\dfrac{\sqrt{3}}{2}$ & $1$         \\ \hline
        $\cos$    & $1$         & $\dfrac{\sqrt{3}}{2}$ & $\dfrac{1}{\sqrt{2}}$ & $\dfrac{1}{2}$        & $0$         \\ \hline
        $\tan$    & $0$         & $\dfrac{1}{\sqrt{3}}$ & $1$                   & $\sqrt{3}$            & Not Defined \\ \hline
        $\mathrm{cosec\,}$ & Not Defined & $2$                   & $\sqrt{2}$            & $\dfrac{2}{\sqrt{3}}$ & $1$         \\ \hline
        $\sec$    & $1$         & $\dfrac{2}{\sqrt{3}}$ & $\sqrt{2}$            & $2$                   & Not Defined \\ \hline
        $\cot$    & Not Defined & $\sqrt{3}$            & $1$                   & $\dfrac{1}{\sqrt{3}}$ & $0$         \\ \hline
    \end{tabular}
\end{document}

Question:

I am looking for answers of following questions, (i) equal width of columns and equal height of rows (ii) text must be align in the center of the cell.

SLx64
  • 2,823
SandyM
  • 2,757

1 Answers1

1

The following MWE produces a table with equal row heights and equal column widths:

\documentclass{article} 
\usepackage[a4paper,top=0.7in,bottom=0.4in,left=0.5in,right=0.5in,headheight=14.5pt]{geometry} 
\usepackage[utf8]{inputenc} 
\usepackage{mathtools} 
\usepackage{array}

\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}

\newcolumntype{P}[1]{%
 >{\vbox to 5ex\bgroup\vfill\centering}%
 p{#1}%
 <{\egroup}}

\begin{document} 
\begin{tabular}{|P{2cm}|*{5}{M{2cm}|}} 
\hline 
$\theta$ & $0$ & $30$ & $45$ & $60$ & $90$ \\ 
\hline 
$\sin$ & $0$ & $\dfrac{1}{2}$ & $\dfrac{1}{\sqrt{2}}$ & $\dfrac{\sqrt{3}}{2}$ & $1$ \\
\hline 
$\cos$ & $1$ & $\dfrac{\sqrt{3}}{2}$ & $\dfrac{1}{\sqrt{2}}$ & $\dfrac{1}{2}$ & $0$ \\ 
\hline 
$\tan$ & $0$ & $\dfrac{1}{\sqrt{3}}$ & $1$ & $\sqrt{3}$ & Not Defined \\ 
\hline 
$\mathrm{cosec\,}$ & Not Defined & $2$ & $\sqrt{2}$ & $\dfrac{2}{\sqrt{3}}$ & $1$ \\ 
\hline 
$\sec$ & $1$ & $\dfrac{2}{\sqrt{3}}$ & $\sqrt{2}$ & $2$ & Not Defined \\ 
\hline 
$\cot$ & Not Defined & $\sqrt{3}$ & $1$ & $\dfrac{1}{\sqrt{3}}$ & $0$ \\ 
\hline 
\end{tabular} 
\end{document}

I have therefore used two new defined column types M and P. M centers its entries vertically and horizontally, while P produces equal height rows. (Note: the definition of P was borrowed from Alain Matthes' answer)

This results in the following output:

enter image description here

If you prefer narrower columns, you can change the width specification (2cm in the above example) to for example 1.25cm. This gives you the following result with automated line wrapping of the entry 'Not Defined':

enter image description here

leandriis
  • 62,593