[Tex/LaTex] How to i make table cells having same width

tables

I want to make a table where all the cells will have equal width.enter image description here

Here the cells width of automobile is bigger than the others.So i want to take all the cells have the width of automobile. I tried this code but don't know how to specify width and height of a cell:

\begin{table}[]
\centering
\caption{My caption}
\label{my-label}
\begin{tabular}{|l|l|l|l|l|l|}
\hline
labels     & airplane & automobile & bird & cat & deer \\ \hline
airplane   &          &            &      &     &      \\ \hline
automobile &          &            &      &     &      \\ \hline
bird       &          &            &      &     &      \\ \hline
cat        &          &            &      &     &      \\ \hline
\end{tabular}
\end{table}

Best Answer

The cleanest way is using the X columntype from tabularx package -- it calculates the column width from the width speficied as 1st argument to tabularx.

enter image description here

\documentclass{article}

\usepackage{tabularx}


\begin{document}

\begin{table}
\centering
\caption{My caption}
\label{my-label}
\begin{tabular}{|*{6}{p{1.5cm}|}}
\hline
labels     & airplane & automobile & bird & cat & deer \\ \hline
airplane   &          &            &      &     &      \\ \hline
automobile &          &            &      &     &      \\ \hline
bird       &          &            &      &     &      \\ \hline
cat        &          &            &      &     &      \\ \hline
\end{tabular}
\end{table}


\begin{table}
\centering
\caption{My caption}
\label{my-other-label}
\begin{tabularx}{\linewidth}{|*{6}{X|}}
\hline
labels     & airplane & automobile & bird & cat & deer \\ \hline
airplane   &          &            &      &     &      \\ \hline
automobile &          &            &      &     &      \\ \hline
bird       &          &            &      &     &      \\ \hline
cat        &          &            &      &     &      \\ \hline
\end{tabularx}
\end{table}


\end{document}
Related Question