LaTeX 中的双行双语段落

发布于 2024-09-02 12:22:13 字数 1459 浏览 5 评论 0 原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

左耳近心 2024-09-09 12:22:13

以下技巧可能会帮助您实现目标。它基于零高度迷你页面的想法,以重叠两个三倍间距的迷你页面。

我将为英语和西班牙语文本使用占位符(分别为 \english\spanish)。另外,请务必包含 setspace 包:

\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.}

通过将顶部块的高度设置为 0pt,我们允许下一个 minipage 与其重叠。

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

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

主要这个想法的问题之一是,如果零高度部分比常规部分长,那么您将需要处理一些挥之不去的重叠文本。 (编辑:这个问题在下面的评论中得到解决,请注意换行符也将是这个想法的一个严重缺陷。)

结果(部分):
替代文本

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

━╋う一瞬間旳綻放 2024-09-09 12:22:13

我不认为有一个包可以做你想要的事情,但是可以使用 \vsplit 自己实现这一点,这在 Tex by Topic(可免费下载,或通过 Lulu 获得 dead-tree 版本)。基本思想是

  1. 您定义两个 vbox,一个用于英语,一个用于西班牙语,并且您希望一次一行取出内容。将这些 vbox 命名为 \ENbox\ESbox
  2. 您需要确定要使用的正确垂直尺寸:这可能是 \lineheight,或者您可能需要不同的值,您必须进行试验。假设 \lineheight 是正确的……
  3. 那么你可以使用 \setbox\nextline=\vsplit\ENbox to \lineheight 得到下一行英文,你可以使用可以使用 \unvbox\ENbox 输出,然后同样从 \ESbox 输出下一行,然后是舌间间隙的一些垂直空间;
  4. 然后,您需要测试循环,可以通过使用 \ht\ENbox\ESbox 查询垂直高度来实现。这一点会很麻烦。

总而言之,这将是一个有点棘手的编码:祝你好运,如果遇到困难,请不要犹豫,在这里提问。

后记 这显然比 Geoff 的更简单的解决方案需要更多的工作,出于某种原因我在写这篇文章时没有看到它,但如果你想摆弄它,它应该更灵活。

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.

那支青花 2024-09-09 12:22:13

如果您想要交错西班牙语和英语段落,并使它们大致正确地排列,那么您想要的就是逐字(或几个单词几个单词)编写翻译,并使用可以包裹很长的光泽包句子。我在使用 gloss.sty 之前就已经这样做过。它的使用示例(目标是用词性来修饰每个单词):

\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

该包使用空格将第一种语言中的单词与第二种“语言”中的单词排列起来。要将一种语言中的多个单词与另一种语言中的单个单词(或多个单词)对齐,请使用大括号将多个单词分组。虽然这里的线条是交错的,但这只是为了我编辑的方便。如果你愿意的话,你可以写很长的行,光泽算法会正确地包裹它们。

我还使用了两列逐段方法,使用

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.

ゝ偶尔ゞ 2024-09-09 12:22:13

在每组行之间添加一个额外的换行符:

%
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
%

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
%
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文