Aligning pieces of words in LaTeX

I’m doing some homework and I need to align something like this:



 un- fold -ed
not-'fold'-past
  'unfolded'

Basically I need to line up the roots in each case. Note that this class has nothing to do with learning LaTeX, I’m using LaTeX because the tipa package is about 9 billion times easier and quicker than the font picker (and god forbid trying to make a vowel chart in Word) when you want to type in IPA, and I need to learn LaTeX anyway. Unfortunately, this sort of alignment is one case where a WYSIWYG editor might be nice, especially since LaTeX is rather finicky about when it wants to eat whitespace and when it doesn’t.

Is there any “simple” way to do this? By simple I mean without hours fiddling with and eyeballing hspace commands. Last time I tried to align things it involved a bunch of macros and hspace toying, took forever, and I still never got it perfect. It would be nice if I could have a command like:



\begin{alignroots}
\word[1]{un-\root{fold}-ed}
\word[1]{not-`\root{fold}'-past}
\word[1]{`un\root{fold}ed'}
\end{alignroots}


(The reason I have the [1] is so that it can match roots in case I want multiple columns of different words). Unfortunately, I’m a bit of a LaTeX newbie so I don’t know if this is easy, or even possible. And if it’s possible I don’t even know where to begin doing this sort of thing.

Missed edit:

Actually I reread the assignment sheet, and it’s not exactly that simple, I need to align all the morphemes with their glosses, except in the whole word in which only the root is aligned, so un- and not- need to be partially aligned and likewise with -ed and -past. It’s not much more complicated than just the root, but it makes it a pain.

To give a more complex example for the formatting of a short sentence may be formatted as:



 He           walk -ed.
 3[sup]rd[/sup].sg.masc.'walk'-past
'He walked.'


(The kerning makes it slightly off, but that’s vBulletin’s fault).
A note is that the “-ed” is aligned at the hyphen with “-past”, as well as the fact that He is aligned with 'He (note quotation mark) and 3[sup]rd[/sup].

My first inclination would be to use the tabular environment (two-dimensional table). I’m still not quite clear on exactly what you want aligned how, but your first example might look something like this:


\begin{tabular}{@{}r@{}c@{}l@{}}
un-&fold&-ed \\
not-`&fold&'-past \\
`un&fold&ed'
\end{tabular}

The {@{}r@{}c@{}l@{}} argument defines a three-column table, the first column justified r[ight], the second c[entered], the third l[eft], with no extra spaces between columns (that’s what all of the @{} mean). The & are the field “tab” separators, and the \ are the line breaks.

This won’t align “un-” and “not-” exactly at the hyphens, because of the quotes. You can get exact alignment with extra quote columns:


\begin{tabular}{@{}r@{}r@{}c@{}l@{}l@{}}
un-&&fold&&-ed \\
not-&`&fold&'&-past \\
\multicolumn{2}{@{}r@{}}{`un}&fold&\multicolumn{2}{@{}l@{}}{ed'}
\end{tabular}

The first row has empty second and fourth columns; the second has quotes there; and the third row places the pre-root and post-root stuff in two-column fields set flush with the root.

Yeah, I was thinking tables might be the way to go, that seems as good a solution as any, thanks.

I was a bit confused as what to align myself, it looks like bound morpheme boundaries are at the ‘-’, so basically the trick is to align any non-free morpheme at ‘-’, and any free morpheme at the first letter (as well as their descriptions, such as 3rd.sg.masc).

You might also try the “tabbing” environment, which is a little less well-known (at least in my circles) but might be better suited for your purposes. In particular, “tabbing” allows you to define & redefine your tab stops on the fly, relative to the text you’re using, and also allows you to place text immediately to the left of tap stops. Here’s my mock-up of your second example:


\setlength{	abbingsep}{0in}

\begin{tabbing}
3rd.sg.masc. {`}\=walk'\=-past \kill
He \>walk\>-ed \\
3rd.sg.masc. \>{`}\'walk' \>-past \\
{`}\'He walked.'
\end{tabbing}

That first line (with the \kill at the end) has to be in there to set the tab stops in the appropriate location for the second line; you’d want to insert whatever the widest text you have is in each “column”, and then kill the line. The length abbingsep gives the whitespace between the pre-tab-stop text and the post-tab-stop text; see the alignment in the last line, where the single left quote is placed to the left of the leftmost tab stop, and “He” is placed to the right.

The syntax for “tabbing” is weird relative to the rest of LaTeX, but not too hard to get the hang of (I had never actually used it before, but it took me about 5 minutes to mock up the above example.) It might be worth a shot.

You should also look at the dcolumn package. It is designed to align tables by the decimal point, but any arbitrary character can be used to do alignment. Another method is this example which is similar to Omphaloskeptic’s suggestion, but using the aligned character as the column separator instead of using nothing.

Also keep in mind that \multicolumn{}{} is not merely used to make text span columns, but rather to make a particular row or cell of the table behave differently than is defined for the whole environment.

And as you’re struggling with this, remember the people doing it in WYSIWYG editors are going to have to redo all of there spacing and tabbing the first time they change fonts, or cause something to wrap inconveniently. Once you get your tabular (or whatever) environment sorted out, you’ll be able to produce those tables perfectly, even if you change other aspects of the document.

The tabular isn’t quite interchangeable, for instance

walk -ed
re- do

and

un- do -able

All need different tables. I actually thought to email my professor (she uses LaTeX for the textbook she’s writing for the class, unlike my section instructor who manages to use the font picker), and she says she uses the ExPex package and said covington and gb4e are also really good. But I’m sure I can find a use for all this eventually, when I go to grad school for machine learning/computer science I’m sure I’ll find plenty of need for various commands. Thanks, guys.

I have to admit, I’ve started to bypass Word completely, unless I need to submit in .doc format for some reason, I’m finding it easier, faster, and generally better to just use LaTeX for everything. After the learning curve is out of the way it seems much better and it always surprises me how pretty it manages to come out with minimal effort. The only problem I’ve had so far is one odd bug I encountered where the Texworks pdf viewer showed my pictures and Adobe Acrobat only showed half of them, was a really weird bug.