22

This seems trivial, but I'd like a single line to have some text with left-justification and right-justification at the same time, eg.

left text here                                               right text here
normal text, normal text, normal text, normal text, normal text, normal text,
normal text, normal text, normal text, normal text, normal text, normal text,
normal text, normal text, normal text, normal text, normal text, normal text,

Would it be some combination of ragged lefts and rights? My (non-working) solution would be something like:

{\raggedleft left text here} {\raggedright right text here}  

2 Answers 2

27

How about \noindent left text here \hfill right text here?

5
  • Thanks, it's perfect! I feel it will take some take for me to internalize all of the commands so that things like this are obvious!
    – Hooked
    Commented Dec 2, 2010 at 22:41
  • 3
    It should be noted that this solution will only work as intended if left text and right text are only on one line. If you want to allow line breaks, you'll need to enclose each block of text in something like a minipage.
    – ESultanik
    Commented Dec 2, 2010 at 22:46
  • @ ESultankik - While locksteps answer is perfect for what I need, it would be useful for myself (and others) if you could post a working minipage example.
    – Hooked
    Commented Dec 2, 2010 at 23:10
  • What if this text is math inside of a displayed math environment? The given solution doesn't work for that situation. Commented Nov 2, 2012 at 12:41
  • @TysonWilliams Sorry, display math mode is not my area of expertise.
    – lockstep
    Commented Nov 2, 2012 at 12:43
17

At the request of Hooked (see the comment to the other answer), here is a working minipage example:

\documentclass{article}
\usepackage{lipsum} %% For the random text
\begin{document}
\noindent\begin{minipage}[b]{0.49\hsize}
  \raggedright
  \lipsum[1]
\end{minipage}
\hfill
\begin{minipage}[b]{0.49\hsize}
  \raggedleft
  \lipsum[2]
\end{minipage}
\lipsum[3]
\end{document}

which produces this: Screenshot of the minipage example.

4
  • I would use a \parbox here. I don't see what the minipage buys you.
    – TH.
    Commented Dec 3, 2010 at 6:18
  • 2
    @TH.: I know that you prefer \parbox to minipage. One reason for using the latter is that one might prefer is semantically: You don't have to wait that long for the matching closing brace. Commented Dec 3, 2010 at 7:32
  • 2
    @Hendrik's semantic argument is exactly why I use it: I can visually parse the \begin and \end statements much quicker than unlabeled braces. @TH is correct though: A \parbox would work just as well. One can always label the closing braces with comments, I guess.
    – ESultanik
    Commented Dec 3, 2010 at 15:02
  • 1
    @Hendrik and Esulanik: One can use \begin{parbox}[b]{.49\linewidth}{ ... }\end{parbox}, but that's sort of silly. I think it comes down to writing readable code. If one is a programmer, one is used to matching braces and using proper indentation to facilitate that matching. That applies here too. That said, your comments make a lot of sense. Thanks.
    – TH.
    Commented Dec 4, 2010 at 3:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .