5

I'm just wondering if there's a way to left-align for a part of my line, while to right-align the rest? Just like what people did in their resume, except I want to make sure that my x's are strictly right-aligned.

For example:

|ooooooooo _______________ xxxxxx|

Where the | is just indicating the margin of the page and the _ represents the space in between.

1
  • \hfill will expand as large as possible. It will also overpower the normal fill at the end of the line. – John Kormylo Sep 17 '16 at 3:18
5

Most likely what you're after is to insert a rubber length that stretches with your content. In LaTeX, this is provided by \hfill. You can insert it between two pieces of text, or any construct that sets in horizontal mode (like a tabular):

enter image description here

\documentclass{article}

\begin{document}

\noindent
Some content on the left \hfill% <----- rubber length
Some content on the right

\bigskip

\noindent
\begin{tabular}{@{} p{.4\linewidth} @{}}
  \raggedright
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
  Aenean orci odio, sollicitudin sed lectus et, accumsan porttitor erat. 
  Donec imperdiet rutrum nibh quis sodales. Nunc sagittis orci enim, 
  a egestas enim congue et.
\end{tabular}\hfill% <----- rubber length
\begin{tabular}{@{} p{.4\linewidth} @{}}
  \raggedleft
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
  Aenean orci odio, sollicitudin sed lectus et, accumsan porttitor erat. 
  Donec imperdiet rutrum nibh quis sodales. Nunc sagittis orci enim, 
  a egestas enim congue et.
\end{tabular}

\end{document}

If you want a rubber rule, use \hrulefill. If you want a rubber dot fill, use \dotfill. Alternatively, use a construction of some leader.

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.