1
{\bf Carnegie Mellon University} \hfill {LTI, School of Computer Science} \hfill {\em July 2008 - Present}
{\bf Tsinghua University} \hfill {School of Software} \hfill {\em July 2008 - Present}

The code above gives this result: enter image description here

How do I make the middle text align to right?

------ Edit ------

What if I have the case that there is some content between these two lines, and I still want the middle text for these two lines to align right? For example:

enter image description here

0

Apart from answers here I think the most flexible way to achieve what you want is to use \minipage environment and apply \flushright to the text.

    \documentclass{article}

\usepackage[a4paper,margin=2cm]{geometry}

%\usepackage{minipage}

\begin{document}

\noindent \begin{minipage}{0.32\textwidth}
\textbf{Carnegie Mellon University}

\textbf{Tsinghua University}
\end{minipage}%
\begin{minipage}{0.35\textwidth}
\begin{flushright}
LTI, School of Computer Science

School of Software
\end{flushright}
\end{minipage}\hfill
\begin{minipage}{0.30\textwidth}
\begin{flushright}
July 2008 -- Present

July 2008 -- Present
\end{flushright}
\end{minipage}

\end{document}

Which produces: aligned text

1

You can use tabular* and also array so you set the formatting in a “centralized” way:

\documentclass{article}

\usepackage[a4paper,margin=2cm]{geometry}

\usepackage{array}

\begin{document}

\noindent
\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  >{\bfseries}l
  r
  >{\itshape}r
  @{}
}
Carnegie Mellon University & LTI, School of Computer Science & July 2008 -- Present \\
Tsinghua University        & School of Software              & July 2008 -- Present
\end{tabular*}

\end{document}

enter image description here

I used geometry because the standard article text width is too small for this table.

1

A good option is to use a tabular:

Try this in your document

\begin{tabular}{l r r}
\textbf{ Carnegie Mellon University} & {LTI, School of Computer Science} &\textit{ July 2008 - Present}\\
\textbf{ Tsinghua University} &{School of Software} & \textit{ July 2008 - Present}\\
\end{tabular}

Here is an update using tabularx

\documentclass[a4paper,10pt]{article}
\usepackage[a4paper, total={7in, 8in}]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}


\newcolumntype{L}{>{\raggedright\arraybackslash}X}%
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}%

\begin{document}

\noindent
{\bf Carnegie Mellon University} \hfill {LTI, School of Computer Science} \hfill {\em July 2008 - Present}\\
{\bf Tsinghua University} \hfill {School of Software} \hfill {\em July 2008 - Present}\vspace*{20pt}

\noindent\begin{tabularx}{\linewidth}{L R R}
\textbf{ \mbox{Carnegie Mellon University}} & {\mbox{LTI, School of Computer Science}} &\textit{ July 2008 - Present}\\
\textbf{ Tsinghua University} &{School of Software} & \textit{ July 2008 - Present}\\
\end{tabularx}

\end{document}

Edit to include text between first and last alligned rows: Code:

\documentclass[a4paper,10pt]{article}
\usepackage[a4paper, total={7in, 8in}]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}


\newcolumntype{L}{>{\raggedright\arraybackslash}X}%
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}%

\begin{document}

Your old code:

\noindent
{\bf Carnegie Mellon University} \hfill {LTI, School of Computer Science} \hfill {\em July 2008 - Present}\\
{\bf Tsinghua University} \hfill {School of Software} \hfill {\em July 2008 - Present}\vspace*{20pt}

My updated code

\noindent\begin{tabularx}{\linewidth}{L R R}
\textbf{ \mbox{Carnegie Mellon University}} & {\mbox{LTI, School of Computer Science}} &\textit{ July 2008 - Present}\\
\multicolumn{3}{p{\linewidth}}{Here you can have any possible content that can break in several lines without
causes any problem to the alligned first and last lines\ldots Be carefullldots you need to use p\verb|\linewidth|
to have this kind of line between the others!}\\
\textbf{ Tsinghua University} &{School of Software} & \textit{ July 2008 - Present}\\
\end{tabularx}

\end{document}

Result:enter image description here

Update with minipage and itemize:

My updated code:\vspace*{10pt}

\noindent\begin{tabularx}{\linewidth}{L R R}
\textbf{ \mbox{Carnegie Mellon University}} & {\mbox{LTI, School of Computer Science}} &\textit{ July 2008 - Present}\\
\\
\multicolumn{3}{p{\linewidth}}{
\begin{minipage}{\linewidth}
\begin{itemize}
  \item Test item one
  \item Test second longer item
  \item These items have nothing to do with the rest alligned tabular...
 \end{itemize}
\end{minipage}}\\
\\
\textbf{ Tsinghua University} &{School of Software} & \textit{ July 2008 - Present}\\
\end{tabularx}

Last result: enter image description here

  • Please replace those obsolete macros with the LaTeX2e version. – TeXnician Jun 20 '17 at 9:33
  • Thanks! What about the case that I have some content between these two lines? See the edit of my question. – Fei Jun 20 '17 at 18:07
  • @Fei I am not sure if you mean what I done... but this is just an option... if you mean someting else just make it more clear... I am updating again with a minipage inside – koleygr Jun 20 '17 at 18:38
  • @koleygr Thank you and this is what I am looking for! Sorry that I don't have enough reputation to give you up-vote... – Fei Jun 21 '17 at 4:08
  • @Fei... I think you can just select the answer as preffered or correct... – koleygr Jun 21 '17 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.