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}  
Hooked
  • 4,046

2 Answers2

27

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

lockstep
  • 250,273
  • 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 Dec 02 '10 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 Dec 02 '10 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 Dec 02 '10 at 23:10
  • What if this text is math inside of a displayed math environment? The given solution doesn't work for that situation. – Tyson Williams Nov 02 '12 at 12:41
  • @TysonWilliams Sorry, display math mode is not my area of expertise. – lockstep Nov 02 '12 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.

ESultanik
  • 4,410
  • I would use a \parbox here. I don't see what the minipage buys you. – TH. Dec 03 '10 at 06: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. – Hendrik Vogt Dec 03 '10 at 07: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 Dec 03 '10 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. Dec 04 '10 at 03:55