[Tex/LaTex] Table content alignment to left/right using tabularx

tablestabularx

I had tried several methods, but still unable to get the correct alignment.
I want the first column to left hand side, then others toward right hand side.

\documentclass{article}
\usepackage{booktabs}
\usepackage[flushleft]{threeparttable}
\renewcommand{\TPTtagStyle}{\itshape} % optional
\usepackage{tabularx, ragged2e} 
\usepackage{threeparttable} 
\begin{document}

\begin{table}[!ht]
\centering

 \begin{tablenotes}
\centering
\small
\item Dependent Variable: Testing1234 
\end{tablenotes}
\begin{threeparttable} 
%\newcolumntype{Y}{>{\RaggedRight\arraybackslash\hsize=2\hsize\linewidth=\hsize}X}
%\newcolumntype{W}{>{\RaggedLeft\arraybackslash\hsize=0.75\hsize\linewidth=\hsize}X}
%\begin{tabularx}{\textwidth}{@{}Y*{3}{W}@{}}
\begin{tabularx}{\textwidth}{l>{\raggedright\arraybackslash}Xlllll}
    \toprule
     \small {\textbf{Source}}
     & \small {\textbf{Type III Sum of Squares}} 
     & \small {\textbf{df}}
     & \small {\textbf{Mean Square}}
     & \small {\textbf{F}}
     & \small {\textbf{Sig.}}\\
     \midrule
    Corrected Model & 14573.300\tnote{a} & 3 & 4857.767 & 40.297 & .000 \\
    Testing1234 & 214036.900 & 1 & 214036.900 & 1775.503 & .000\\
    Testing1234 & .100 & 1 & .100 & .001 & .977\\
    Testing1234Testing1234 & 14137.600 & 1 & 14137.600 & 117.276 & .000\\
    Testing1234Testing1234Testing1234 & 435.600 & 1 & 435.600 & 3.613 & .065 \\
    \bottomrule
    \end{tabularx}
\footnotesize 
\begin{tablenotes}
\item[a]Testing1234Testing1234Testing1234 % the footnote itself 
\end{tablenotes}

\end{threeparttable}
\caption{Testing1234
    \label{tab:test123} }
\end{table}

\end{document}

enter image description here

I had tired:

\newcolumntype{Y}{>{\RaggedRight\arraybackslash\hsize=2\hsize\linewidth=\hsize}X}
\newcolumntype{W}{>{\RaggedLeft\arraybackslash\hsize=0.75\hsize\linewidth=\hsize}X}
\begin{tabularx}{\textwidth}{@{}Y*{3}{W}@{}}

not working

\begin{tabularx}{\textwidth}{l>{\raggedright\arraybackslash}Xlllll}

not working too

\begin{tabularx}{\textwidth}{l>{\raggedright\arraybackslash}Xrrrrr}

Getting more confused.

Best Answer

With \begin{tabularx}{\textwidth}{>{\raggedright\arraybackslash}Xrrrrr} you can get the desired result. I have also used the \thead command to replace repeated \small and \textbf commands and inserted manual linebreaks in the column headers of the second and fourth column:

enter image description here

\documentclass{article}
\usepackage{booktabs}
\usepackage[flushleft]{threeparttable}
\renewcommand{\TPTtagStyle}{\itshape} % optional
\usepackage{tabularx, ragged2e} 

\usepackage{makecell}
\renewcommand\theadfont{\small\bfseries} 
\begin{document}

\begin{table}[!ht]
\centering
\small
Dependent Variable: Testing1234 
\begin{threeparttable} 
\begin{tabularx}{\textwidth}{>{\raggedright\arraybackslash}Xrrrrr}
    \toprule
     \thead{Source}
     & \thead{Type III\\ Sum of\\ Squares} 
     & \thead{df}
     & \thead{Mean\\ Square}
     & \thead{F}
     & \thead{Sig.}\\
     \midrule
    Corrected Model & 14573.300\tnote{a} & 3 & 4857.767 & 40.297 & .000 \\
    Testing1234 & 214036.900 & 1 & 214036.900 & 1775.503 & .000\\
    Testing1234 & .100 & 1 & .100 & .001 & .977\\
    Testing 1234Tes ting1234 & 14137.600 & 1 & 14137.600 & 117.276 & .000\\
    Testing 1234Test ing12 34Te ting1234 & 435.600 & 1 & 435.600 & 3.613 & .065 \\
    \bottomrule
    \end{tabularx}
\footnotesize 
\begin{tablenotes}
\item[a]Testing1234Testing1234Testing1234 % the footnote itself 
\end{tablenotes}
\end{threeparttable}
\caption{Testing1234\label{tab:test123}}
\end{table}

\end{document}
Related Question