Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to create some documents using the flashcards macros, and I'd like to have the text aligned like follows

    ____________________________________
   |                                    |
   | A string      An Xtra long string  |
   | B string                 C string  |
   | An Xtra long string 2    D string  |
   |                                    |
    ------------------------------------

I tried using the tabular* environment, which seems quite suitable, used as follows:

\begin{tabular*}
A string               & An Xtra long string \\
B string               & C string \\
An Xtra long string 2  & D string
\end{tabular*}

Unfortunately the result overflows horizontally, something like this:

    ____________________________________
   |                                    |
   | A string               An Xtra long string
   | B string                          C string
   | An Xtra long string 2             D string
   |                                    |
    ------------------------------------

So I've tried using makebox, like this:

\makebox[.48\linewidth][l]{A string} 
\makebox[.48\linewidth][r]{An Xtra long string} \\
\makebox[.48\linewidth][l]{B string} 
\makebox[.48\linewidth][r]{C string} \\    
\makebox[.48\linewidth][l]{An Xtra long string 2} 
\makebox[.48\linewidth][r]{D string}

But this results in too much vertical padding, something like this:

     ____________________________________
    |                                    |
    | A string      An Xtra long string  |
    |                                    |
    | B string                 C string  |
    |                                    |
    | An Xtra long string 2    D string  |
     ------------------------------------

Which is also not the desired result.

I think (hope) I've clearly demonstrated the outcome I desire. So far I've been mucking about, but I suspect there's a relatively easy way to accomplish this.

I would be grateful for any feedback or suggestions that you think may be of assistance.

share|improve this question
    
Note that you don't have to (and shouldn't) sign with your name since it automatically appears in the lower right corner of your post. –  Hendrik Vogt Jan 20 '11 at 7:17
add comment

2 Answers

up vote 3 down vote accepted

Here's one option... use \hfill.

\documentclass{article}
\begin{document}
\noindent
\parbox{2in}{%
A string \hfill An Xtra long string \\
B string \hfill C string \\
An Xtra long string 2 \hfill  D string
}
\end{document}

(You don't really need the parbox; it's just that the point is easiest to see with a narrower width.)

alt text

I have another option which I'll post separately so it can be voted on separately or accepted/unaccepted separately.

share|improve this answer
    
This works, but I have to add \vspace*{-0.9ex} to the end of all the lines. Thanks! –  Brian M. Hunt Jan 20 '11 at 0:20
    
Another great option in the memoir class is \leftspringright{⟨lfrac⟩}{⟨rfrac⟩}{⟨ltext⟩}{⟨rtext⟩}, though it requires some tinkering to make it work. :) –  Brian M. Hunt Jan 21 '11 at 2:27
add comment

Another option is to use a tabbing environment:

\documentclass{article}
\begin{document}
\parbox{2in}{%
\begin{tabbing}
A string \` An Xtra long string \\
B string \` C string \\
An Xtra long string 2 \` D string
\end{tabbing}
}
\end{document}

I was going to post another screenshot, but I can't tell the difference between this output and the one I posted earlier, so...

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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