For the first column, I want the header cell to be centered but the other rows to be left-aligned with some space before. How to achieve this ? Can I define different spacing for the same column in multiple rows for a LaTeX table ? The column width specifications using \hsize in tabularx should not be disturbed.
\documentclass[conference]{IEEEtran}
\usepackage{tabularx}
\usepackage{booktabs}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\begin{document}
\begin{table}[!h]
\renewcommand{\arraystretch}{1.3}
\caption{Comparison of Algorithm Results}
\centering
\begin{tabularx}{\columnwidth}
{ @{\hspace{.2em}} >{\hsize=1.5\hsize}L *{4}{>{\hsize=0.875\hsize}C} @{} }
\toprule
\centering\arraybackslash\textbf{Optimization Algorithm} & \textbf{Swarm Size} & \textbf{No. of Iterations} & \textbf{Final Wirelength} & \textbf{Best Value Cost Fn.}\\
\midrule
\hspace{.5em} Short Text & 10 & 1000 & 100 & -- \\
\hspace{.5em} Slightly Longer Text that Wraps & 20 & 2000 & 200 & 10.5 \\
\hspace{.5em} Slightly Longer Text that Wraps & 30 & 3000 & 300 & 20.55 \\
\hspace{.5em} Short & 40 & 4000 & 400 & 30.5 \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
EDIT: Since my question was misunderstood, let me restate that what I want is some alternative to \hspace that adds space before every line in the paragraph, and no indent for the first line. Or maybe indent all lines. Illustrated below, I want all text to start immediately at the right of the red line. My problem is where the text wraps and \hspace cannot help me there.
Manually adding space after the text wrap is not an acceptable solution. I want automated cell padding or paragraph padding/reshape that affects all lines of the paragraph.





tabularxallows relative width specifications with X andsiunitxallows decimal alignment with S. How to do both ? – geekshift Dec 27 '16 at 20:23