Two-line bilingual paragraph in LaTeX

Interlinear gloss can be used to compose a translation of a document.

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

This is usually done in a single word or morpheme in morpheme. However, I would like to do it differently, translating entire paragraphs at a time. The following link and image are an example of what I want to do, although I want to do this for other text that is larger.

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

image three pigs

While I'm not interested in the order of words or phrases that change the order between languages. That is, I do not mind if the words in the paragraph are not aligned or the length of one paragraph is much longer than the other, causing an overhang.

As far as I can tell, the following packages do not fit 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 do not want to do this manually as follows:

 \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 macro to automatically use English and Spanish texts alternating with line breaks when the end of each line is reached for each. How can I compose this simple two-line paragraph in Latex in a more automated way (without manually adding line breaks)?

+4
source share
4 answers

The next hack can help you achieve your goal. It is based on the idea of ​​a zero-height mini-page to overlap two triple mini-pages.

I will use placeholders for text in English and Spanish ( \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 setting the height of the top block to 0pt , we allow the next minipage overlap it.

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

The main one of the problems associated with this idea is that if a section of zero height is longer than a regular section, then you will have to deal with some kind of long overlapping text. (Change: this problem is resolved in the comment below, note that line breaks will also be a serious flaw in this idea.)

Result (partially): alt text

+4
source

I don’t think there is a package that needs to be done, but you can implement it yourself using \vsplit , which is well documented in Tex by Topic (available for free download or in a dead edition via Lulu). main idea

  • You define two vboxes, one for English, one for Spanish, and you want to display the contents one line at a time. Call these vboxes \ENbox and \ESbox ;
  • You need to determine the correct vertical dimension: it may be \lineheight , or you may need a different value, you will have to experiment. Assuming \lineheight right ...
  • ... then you can get the next line in English using \setbox\nextline=\vsplit\ENbox to \lineheight , which you can output with \unvbox\ENbox , and then the next line from \ESbox , then some vertical space for inter-syllable space;
  • Then you need to check the loop, which you can do by querying the vertical heights using \ht , \ENbox and \ESbox . This bit will be inconvenient.

All in all, it will be a bit complicated coding: good luck and feel free to ask questions here if you have any difficulties.

Postscript This is obviously much more than Jeff has a much simpler solution, which for some reason I did not see when I wrote this, but it should be more flexible if you want to mess with it.

+2
source

If you want to alternate with paragraphs from Spanish and English, and if they line up correctly, then you want to write your translations by word (or a few words in a few words) and use the gloss package, which can wrap long sentences. I did this before using gloss.sty . An example of its use (the goal was to cover up each word with its own part of speech):

 \gloss Both knowledge and wisdom extend man 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 contains words from the first word with words from the second “language” using spaces. To align multiple words in one language with one word (or several words) from another language, use braces to group multiple words. Although the lines here are interlaced, this is only for my editing. You could write really long lines if you want, and the gloss algorithm would wrap them properly.

I also used a two-step “paragraph by paragraph” approach using parallel .

+1
source

add an extra line break 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 % 
0
source

Source: https://habr.com/ru/post/1310886/


All Articles