# Table text left align But heading remain centered

Here is the table, I wanted the heading of the table i.e., Ref.no, objectives etc remain in center however, text gets aligned on left side. Secondly if I write more words or little paragraph in the cell then it should remain adjust in same cell not like(3rd column 1st cell). Thirdly words remain packed no extra space like in 1st row Hybrid has left and right space. Thank you in advance. Here is the code

\begin{table*}[h!]
%\setlength\extrarowheight{0.01pt}
\caption{Heuristic techniques}\label{title}
%\renewcommand{\arraystretch}{0.9}
\setlength{\tabcolsep}{25pt}
\centering
\begin{tabular}%{|m{1.5cm}|m{1.5cm}|m{4cm}|m{3cm}|}
\hline

\textbf{\small Ref. no(s)}   &  \textbf{\small Objective(s)} & \textbf{\small Distinctive attributes} &  \textbf{\small Remarks} \\ %\midrule
\hline
fjldsajfdlfjdlf&asdf \\
\hline
hh \cite{9} & Cost  &  area & enhanced     \\
\hline
hh \cite{10}& Cost & problems & Practical\\
\hline
jj \cite{11}& Cost  & simplicity & ignored\\
\hline
jjj\cite{12}& comfort& Cost  & S  \\
\hline
kk\cite{13}& Cost &   integration& time \\
\hline

\end{tabular}
\end{table*}


You can use tabularx to benefit from all the available hspace. The column with long text can be set X, columns with shorter wrapping text can be set as m{..}, all other columns can be set l. To center any cell use \multicolumn{1}{c|}{..}. Notice the line \renewcommand{\tabularxcolumn}[1]{m{#1}} which redefines X to behave like m. Finally remove \setlength{\tabcolsep}{25pt}, this is responsible for the extra padding to the left and right of cells.

\documentclass[12pt]{article}
\usepackage{booktabs,tabularx}
\begin{document}

\begin{table}[!tbh]
\centering
\caption{Heuristic techniques}\label{title}
%\setlength{\tabcolsep}{25pt}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\begin{tabularx}{\textwidth}{|m{1.5cm}|l|X|l|}
\hline
\textbf{\small Ref. no(s)}   & \textbf{\small Objective(s)} & \multicolumn{1}{c|}{\textbf{\small Distinctive attributes}} & \textbf{\small Remarks} \\ \hline
hh \cite{9}                  & Cost    & area                                            & enhanced     \\ \hline
hh \cite{10}                 & Cost    & problems                                        & Practical\\\hline
jj \cite{11}                 & Cost    & simplicity                                      & ignored\\\hline
jjj\cite{12}                 & comfort & Cost                                            & S  \\\hline
kk\cite{13}                  & Cost    & integration                                     & time \\\hline
\end{tabularx}
\end{table}

\end{document}


• ! I have one more thing to know, if I have to reduce the size of third column i.e., distinctive attributes and increase the size of second column then what else I do other than X,l, and Lastly if I want to put my own sizes like you did 1.5 how can I do that for all columns (But text should remain in the cell donot enter into new column). Thanks in advance – Shane Oct 2 '19 at 19:46
• If you want columns 2 and 3 have the same width, use X for both of them. The advantage of X is that you can use all the available text width without calculating widths manually. Still, you can specify the widths manually with X using >{\hsize=<some factor>}X, refer to the tabularx package documentation for more details. – AboAmmar Oct 2 '19 at 21:11

Using \thead from the makecell package, there is no need for \multicolumn, \textbf and \small:

\documentclass[12pt]{article}
\usepackage{booktabs,tabularx}
\usepackage{makecell}
\begin{document}

\begin{table}[!tbh]
\centering
\caption{Heuristic techniques}\label{title}
%\setlength{\tabcolsep}{25pt}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\begin{tabularx}{\textwidth}{|m{1.5cm}|l|X|l|}
\hline