views:

227

answers:

4

An interlinear gloss can be used to layout a translation of a document.

http://en.wikipedia.org/wiki/Interlinear_gloss

Usually this is done word-by-word or morpheme-by-morpheme. However, I would like to do this in a different way, translating entire paragraphs at a time. The following link and image is an example of what I want done, though I want to do it for a different text which is larger.

http://www.optimnem.co.uk/learning/spanish/three-little-pigs.php

image three pigs

For now I am not interested in taking into account the order of words or phrases that change order between languages. That is, I don't mind if the words in the paragraph are not aligned or if the length of one paragraph is much longer than the other, causing an overhanging line.

As far as I can tell, the following packages do not meet my needs:

covingtn.sty
cgloss4e.sty
gb4e.sty
lingmacros.sty - shortex

Here is the english version:

In the heart of the forest lived three little pigs who were brothers. The wolf always was chasing them in order to eat them. In order to escape the wolf, the pigs decided to make a house each. The smallest made his from straw, to finish first and go out to play. The middle one constructed a cottage from wood. Seeing that his little brother had finished already, he hurried to go and play with him. The oldest worked on his house of brick. 'You'll soon see what the wolf does with your houses,' he scolded his brothers but they were having a great time.

Here is the spanish version:

En el corazón del bosque vivían tres cerditos que eran hermanos. El lobo siempre andaba persiguiéndoles para comérselos. Para escapar del lobo, los cerditos decidieron hacerse una casa. El pequeño la hizo de paja, para acabar antes y poder irse a jugar. El mediano construyó una casita de madera. Al ver que su hermano perqueño había terminado ya, se dio prisa para irse a jugar con él. El mayor trabajaba en su casa de ladrillo. - Ya veréis lo que hace el lobo con vuestras casas - riñó a sus hermanos mientras éstos se lo pasaban en grande.

I don't want to do it manually like this:

\documentclass{article}
\usepackage[margin=1in, paperwidth=8.5in, paperheight=11in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{url}
\begin{document}

\noindent
\url{http://www.optimnem.co.uk/learning/spanish/three-little-pigs.php}\\
\\
\indent
En el corazón del bosque vivían tres cerditos que eran hermanos. El lobo siempre\\
\indent
In the heart of the forest lived three little pigs who were brothers. The wolf always\\
\\
%
andaba persiguiéndoles para comérselos. Para escapar del lobo, los cerditos decidieron\\
was chasing them in order to eat them. In order to escape the wolf, the pigs decided to\\
\\
%
hacerse una casa. El pequeño la hizo de paja, para acabar antes y poder irse a jugar.\\
make a house each. The smallest made his from straw, to finish first and go out to play.\\
\\
%
El mediano construyó una casita de madera. Al ver que su hermano perqueño había\\
The middle one constructed a cottage from wood. Seeing that his little brother had\\
\\
%
terminado ya, se dio prisa para irse a jugar con él. El mayor trabajaba en su casa de\\
finished already, he hurried to go and play with him. The oldest worked on his house of\\
\\
%
ladrillo. - Ya veréis lo que hace el lobo con vuestras casas - riñó a sus hermanos\\
brick. 'You'll soon see what the wolf does with your houses,' he scolded his brothers\\
\\
%
mientras éstos se lo pasaban en grande.\\
but they were having a great time.\\
\\

\end{document}\\

I would like to use a package or a macro to automatically have the english and spanish texts interspersed with line breaks when the end of the line has been reached for each. How can I layout this simple dual-line biligual paragraph in Latex in a more automated way (without manually adding line breaks)?

A: 

put an extra line break in between each set of lines:

%
andaba persiguiéndoles para comérselos. Para escapar del lobo, los cerditos decidieron

was chasing them in order to eat them. In order to escape the wolf, the pigs decided to
%
Mica
Thank you for your answer. I'm not sure I explained myself clearly. I want to type a full paragraph of english followed by a full paragraph of spanish and have them interspersed with line breaks placed automatically. What you have typed is the same as my example except you used substituted an actual line break where I have \\. You still need to manually add these. I may delete my example, it seems to be more confusing than helpful.
D W
that's going to be pretty difficult to do with LaTeX, i believe because TeX uses a "best fit" algorithm to typeset letters and words and so forth. So unless you have the same letters exactly, it's going to difficult to do with tex. If it's paragraph by paragraph, why not take a two column approach, one column for english, one for spanish. sorry i couldn't help!
Mica
Yes a two column approach may be useful. Hopefully though someone will know how to do this the way I am asking. If TeX can automatically place line breaks for one line I'm think someone must have it working for dual-line. Remember I don't mind if the words from each line don't line up.
D W
+2  A: 

The following hack may help you achieve your goal. It's based on the idea of a zero-height minipage to overlap two triple-spaced minipages.

I'll use placeholders for the English and Spanish text (\english and \spanish respectively). Also, be sure to include the setspace package:

\usepackage{setspace}
\def\english{In the heart of the forest lived three little pigs who were brothers. The wolf always was chasing them in order to eat them. In order to escape the wolf, the pigs decided to make a house each. The smallest made his from straw, to finish first and go out to play. The middle one constructed a cottage from wood. Seeing that his little brother had finished already, he hurried to go and play with him. The oldest worked on his house of brick. 'You'll soon see what the wolf does with your houses,' he scolded his brothers but they were having a great time.}
\def\spanish{En el corazón del bosque vivían tres cerditos que eran hermanos. El lobo siempre andaba persiguiéndoles para comérselos. Para escapar del lobo, los cerditos decidieron hacerse una casa. El pequeño la hizo de paja, para acabar antes y poder irse a jugar. El mediano construyó una casita de madera. Al ver que su hermano perqueño había terminado ya, se dio prisa para irse a jugar con él. El mayor trabajaba en su casa de ladrillo. - Ya veréis lo que hace el lobo con vuestras casas - riñó a sus hermanos mientras éstos se lo pasaban en grande.}

By giving the top block a height of 0pt we allow for the next minipage to overlap it.

\begin{minipage}[t][0pt]{\linewidth}
    \setstretch{3}
    \english
\end{minipage}

\begin{minipage}[t]{\linewidth}
    \setstretch{3}
    \spanish
\end{minipage}

The primary One of the problems with this idea is that if the zero-height section is longer than the regular section, then you'll have some lingering overlapping text to deal with. (Edit: This problem is addressed in the comment below, note that line-breaks will also be a serious drawback to this idea.)

The result (in part): alt text

Geoff
It looks like my copy-and-paste of the Spanish dropped all accented characters. Sorry about that.
Geoff
+1 Clever: it took me a while to figure it out. I know how to deal with the overlap: you can first set the text in vboxes, and calculate the difference in height. A potentially more serious problem is that I doubt you can tell a zero-height minipage to stop at the end of the page, a problem if you want to typeset long translations, which means you have to vsplit before you overlap texts.
Charles Stewart
@Charles, good point.
Geoff
+1 Thanks for the reply and the working example @Geoff. \usepackage[utf8]{inputenc} is what I used to retain the spanish characters. Your solution works when I try it out. I'm just now trying to learn about vspilt so I can fix the problems at the end of the page.
D W
+2  A: 

I don't think there is a package to do what you want, but it is possible to implement this yourself using \vsplit, which is well documented in Tex by Topic (availble for free download, or in the dead-tree edition via Lulu). The basic idea is

  1. You define two vboxes, one for the English, one for the Spanish, and you want to take out the contents one line at a time. Call these vboxes \ENbox and \ESbox;
  2. You need to determine the correct vertical dimension to use: this might be \lineheight, or you might need a different value, you will have to experiment. Assuming \lineheight is right ...
  3. ... then you can get the next line of English using \setbox\nextline=\vsplit\ENbox to \lineheight, which you can output using \unvbox\ENbox, then likewise the next line from \ESbox, then some vertical space for the intergloss gap;
  4. Then you need to test the loop, which you can do by querying the vertical heights, using \ht, of \ENbox and \ESbox. This bit will be fiddly.

All-in-all, this will be somewhat tricky coding: good luck, and don't hesitate to ask questions here if you run into difficulties.

Postscript This is obviously much more work than Geoff's much simpler solution, which for some reason I hadn't seen when I wrote this, but it should be more flexible if you want to fiddle with it.

Charles Stewart
+1 thank you for the reply. I'm looking into \vsplit now.
D W
I guess this was too difficult... bummer. I'm curious to see how this would pan out anyway. It would be especially cool to make some environment that detected periods and tried to add space to the shorter sentence to align all sentence beginnings.
Geoff
@D W, @Geoff: This is something my clients might use - I'd be interested in writing up a proper Latex package to do this. Coworkers?
Charles Stewart
I have no experience with writing environments or mucking with TeX directly, so my answer is "no". I am curious though. It would be helpful to translate technical documents to plain English, or to present two different ways of phrasing something. (Like a good answer vs. bad answer.)
Geoff
Hi Charles, thanks for asking. I'm interested in writing a Latex package but haven't really even gone through one in detail. I do programming in languages like python, but am new to Latex. Thus I think I would be little help to you. Such a package would be useful though, I'm surprised it hasn't been done. I've done some Google searching and talked to a linguist and I don't think it exists.
D W
@Geoff, The sentence alignment would be useful. You'd have to be careful though, I've seen one sentence translate to two. That would cause missalignment of all other sentences. Ideally you'd be able to indicate this somehow so that the particular sentence could align to two in the other language.
D W
+1  A: 

If you want to interlace Spanish and English paragraphs, and have them line up approximately correctly, then what you want is to write your translations word-by-word (or several words by several words), and use a gloss package that can wrap long sentences. I've done this before using gloss.sty. An example of its use(the goal was to gloss each word with its part of speech):

\gloss Both knowledge and wisdom extend man's reach. Knowledge led to
     cjc  nn0       cjc nn0    vvb    {nn0 pos} {nn0 pun} nn0 vvd prp
\gloss computers, wisdom to chopsticks. Unfortunately our association is
       {nn2 pun}  nn0    prp {nn2 pun}  av0           dps nn1        vbz
\gloss overinvolved with the former. The latter will have to wait for a
       ad0         prp  at0 {nn0 pun} at0 nn0  vm0  vhb to0 vvb  avp at0
\gloss more sublime day.
       av0  aj0     {nn1 pun}
\unhbox\gline

The package lines things up words from the first language with words from the second "language" using spaces. To line up multiple words in one language with a single word (or multiple words) from the other language, use braces to group the multiple words. Though the lines here are interlaced, this is just for my editing convenence. You could write really long lines if you wanted to, and the gloss algorithm will wrap them properly.

I've also used a two-column paragraph-by-paragraph approach using the parallel package.

Ken Bloom
Hi @Ken, thanks for the comment. I'm not interested in a two column solution. I suppose the link you gave me for gloss is different from this gloss: http://tug.ctan.org/tex-archive/macros/latex/contrib/gloss/ correct? I'm fairly new to latex, could you provide link to an example usage of that gloss.sty, or even better provide a snippet of the translation you've done before using that style file.
D W
No, it's not the same as macros/latex/contrib/gloss from CTAN
Ken Bloom