[Tex/LaTex] How to align text left/center/right in the same line use \hfill

horizontal alignment

I use the same latex for two piece of information, but the output alignment is a bit different:

Syntax:

\noindent \textbf{Udacity} \hfill Machine Learning Nanodegree \hfill Aug. 2014 -- Sept. 2015\linebreak

\noindent \textbf{Singapore Management University} \hfill M.S. in Data Management and Analytics \hfill Aug. 2014 -- Aug. 2015

Output
enter image description here

Best Answer

I think the easiest way to accomplish the alignment isn't using \hfill but a tabular or tabularx environment:

\documentclass[]{article}

\usepackage{geometry}
\usepackage{array}
\usepackage{tabularx}

\begin{document}
\noindent
\begin{tabularx}{\linewidth}{
        @{}
        >{\bfseries}X
        >{\centering}X
        r
        @{}}
    ~\textsc{Education}\\
    \hline
    Udacity & Machine Learning Nanodegree & Aug. 2014 -- Sept. 2015\cr
    Singapore Management University & M.S. in Data Management and Analytics & Aug.
    2014 -- Aug. 2015\\
\end{tabularx}

\end{document}

enter image description here