打印直行翻译:如何自动混合两段,交替打印行

打印直行翻译:如何自动混合两段,交替打印行

我正在写一篇外语文档,比如法语,想把一些法语段落和英语翻译放在一起。但我想打印一行法语文本,一行对应的英语文本,一行法语文本,一行对应的英语文本,等等。

例如,如果我有以下两段:

我不知道该选什么,但我同意,雷纳德说。男人认识的时间还不到那个时候。我已购买了卖家提供的所有优质商品。但既然不存在朋友的买卖点,那么人们就不存在更多的朋友。如果你看到一个朋友,请允许我这么做!

狐狸说,我们只知道我们驯服的东西。人们再也没有时间去了解任何东西。他们购买已经为小贩制作好的东西。但是由于没有朋友的小贩,他们就不再有朋友了。如果你想要朋友,就驯服我吧!

我希望它们能够像这样自动打印,并提供直行翻译:

On ne connaît que les choses que l'on apprivoise, dit le renard. Les hommes n'ont plus 
We only know the things that we tame, said the fox. People no longer have 

le temps de rien connaître. Ils achètent des choses toutes faites chez les marchands.
the time to know anything. They buy things already made for peddlers. 

Mais comme il n'existe point de marchands d'amis, les hommes n'ont plus d'amis. 
But since there are no peddlers of friends, they no longer have friends. 

Si tu veux un ami, apprivoise-moi!
If you want a friend, tame me! 

因此,我正在寻找一种混合两个段落的方法,最终找到一种提供同步信息的方法,告诉 Latex 哪些部分必须保持在一起。理想情况下,我希望自动处理此过程,这样修改页面布局或字体大小时,我不必亲自重新格式化文本。

答案1

类似这样的划分,但同步程度更高,在语言学中很常见。http://www.essex.ac.uk/linguistics/external/clmt/latex4ling/大部分语言学的 LaTeX 资源都已收集。具体来说,您的同步文本类似于所谓的注释在语言学中;这些可以通过处理cgloss4e.sty。参见http://www.essex.ac.uk/linguistics/external/clmt/latex4ling/examples/更多细节。

答案2

很有趣的想法。以下是概念证明:

\documentclass{article}
\usepackage{setspace}

\newlength{\syncheight}
\newcommand{\sync}[2]{%
\setlength{\syncheight}{\baselineskip}
\begin{spacing}{3}
\setlength{\parindent}{0pt}

\begin{minipage}[t][0pt][t]{\textwidth}
#1
\end{minipage}

\vspace{-2\syncheight}
#2
\end{spacing}
}

\begin{document}

The following paragraph is in both English and French.
That is to say, there are two paragraphs, one is in French and one in English,
and each is a translation of the other.

\sync{%
On ne connaît que les choses que l'on apprivoise, dit le renard. Les hommes
n'ont plus le temps de rien connaître. Ils achètent des choses toutes faites
chez les marchands.  Mais comme il n'existe point de marchands d'amis, les
hommes n'ont plus d'amis. Si tu veux un ami, apprivoise-moi!
}{%
We only know the things that we tame, said the fox. People no longer have
the time to know anything. They buy things already made for peddlers. But
since there are no peddlers of friends, they no longer have friends. If you
want a friend, tame me!
}

The preceeding paragraph is in both English and French.
That is to say, there are two paragraphs, one is in French and one in English,
and each is a translation of the other.

\end{document}

此实现存在的问题:

  1. 翻译段落前后的空白过多(也许这其实是件好事!)。可能不太难克服。

  2. 如果法语段落比英语段落长,那么多余的行将导致以下文本的间距出现问题。这个不确定;如果可以测量段落的高度并比较两个长度,那就很容易了。

  3. 它无法正确地跨越页面边界:法语版只会继续沿旧页面向下,而英语版则会正确地越过旧页面。这可能有点棘手。

(很久以前,我使用过类似的技巧来制作小册子,当时需要一些超出\marginpar能力范围的边注。我的灵感来自于不太短的指南在谈论 parboxes 的宽度等时:“在极端情况下,您甚至可以将宽度设置为 0pt,这样框内的文本将被排版而不会影响周围的框。” 我补充道:“当然,如果您真的可以证明,您可以对高度做同样的事情。”)

相关内容