# [Tex/LaTex] Right alignment of column in table column

columnstables

I have a table defined as follows where the first column is right-justified:

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{array}
\begin{document}
\begin{table}
\centering
\begin{tabular}{>{\hfill}p{3.50cm}p{5.50cm}p{5.50cm}}
\hline\noalign{\smallskip}
\textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} \\ [0.5ex]
\hline\noalign{\smallskip}
1 & text & text \\
2 & text & text \\
\hline\noalign{\smallskip}
\end{tabular}
\caption{thisTable.}
\label{tab:thisTable}
\end{table}
\end{document}


However, the column heading of the first column is also right-justified.

Can I change the column heading to be left-justified but leave the values contents of the data part of the column right-aligned?

Can I change the column heading to be left-justified but leave the values contents of the data part of the column right-aligned?

Yes. Just place the cell's contents in a \multicolumn{1}{l}{...} "wrapper".

Incidentally, instead of using the somewhat kludgy \hline\noalign{\smallskip} directives, I suggest you load the booktabs package and use its macros \toprule, \midrule, and \botttomrule to get well-spaced horizontal lines.

And, instead of the >{\hfill}p{3.50cm} specification of the left-most column, I suggest you load the array and ragged2e packages and define a raggedleft (flushright) column type that takes a width parameter, as is done in the example below.

\documentclass{article}
\usepackage[margin=1in,a4paper]{geometry}  % choose margins appropriately
\usepackage{array,booktabs,ragged2e}
\newcolumntype{R}[1]{>{\RaggedLeft\arraybackslash}p{#1}}
\begin{document}
\begin{table}
\centering
\begin{tabular}{ R{3.50cm} p{5.50cm} p{5.50cm} }
\toprule
\multicolumn{1}{l}{\textbf{Column 1}} & \textbf{Column 2} & \textbf{Column 3} \\
\midrule
1 & text & text \\
2 & text & text \\
\bottomrule
\end{tabular}
\caption{thisTable.}
\label{tab:thisTable}
\end{table}
\end{document}


Addendum to address the OP's follow-up question: If the cell in question has a lot of text that needs to span several lines, you can still use \multicolumn, but not with the l column type specifier. E.g., you might type

\newcolumntype{L}[1]{>{\RaggedRight\arraybackslash}p{#1}}


in the preamble and then write

\multicolumn{1}{L{3.50cm}}{An incredibly long header that occupies several lines.}


\multicolumn{1}{l}{\textbf{Column 1}}

In short, \multicolumn is a very powerful and flexible tool.