[Tex/LaTex] Extra spacing and right align

horizontal alignmentspacing

I am working on a list of courses that I have taken. The following code:

Math 100--Trivialities \hfill Professor Jane Doe
\begin{flushright}
Grade: A
\end{flushright}

produces

enter image description here

Notice that there is an extra line space between the professor's name and grade. Is it possible to remove that space so that the Grade appears on the next line as if it were typed in a paragraph? In my mind, I'm thinking of it looking something like:

Math 100-Trivialities        Professor Jane Doe
                                       Grade: A

Best Answer

Here are two options for achieving your requested output:

enter image description here

\documentclass{article}
\begin{document}
\noindent Math 100--Trivialities \hfill Professor Jane Doe \par
\hfill Grade: A

\bigskip

\noindent Math 100--Trivialities \hfill
\begin{tabular}[t]{r@{}}
  Professor Jane Doe \\
  Grade: A
\end{tabular}
\end{document}

\noindent ensures that the left entry is flush with the left margin.

The first inserts a paragraph break and then flushes Grade: A to the right using \hfill. The second uses the fact that a tabular is traditionally [c]enter-aligned and overriding that with [t]op. Using a column specification of r@{} adds the contents right-aligned with no column separation on the right.

If you're using a document style that has a non-zero \parskip, you can revert this in the first approach, if needed. My MWE provides no \parskip.


Another, perhaps "overkill-ish" way of obtaining the output would be to use flushright and setting the first entries (on the same line) in a box of width \linewidth:

\begin{flushright}
\makebox[\linewidth]{Math 100--Trivialities \hfill Professor Jane Doe}
Grade: A
\end{flushright}
Related Question