我正在编写脚本来生成同步文本,以帮助学习语言。我希望多条文本流在段落中一起流动,在我指示的地方同步,否则独立流动。
第二个示例不是语言“注释”的示例,并且无法使用迄今为止建议的语言学包生成。请注意两个平行的文本流如何具有独立的换行符:
我对 TeX 和 LaTeX 了解足够多,因此我相信这很难在一次通过中完成,而且完全使用 TeX。如果我现在要编写代码,我会在第一次 LaTeX 传递中测量每个单词,然后使用外部编程语言为第二次 LaTeX 传递规划段落。用 TeX 表达必要逻辑的想法对我来说听起来很痛苦。
但是,如果有人知道或能想象如何完全在 TeX 或 LaTex 中做到这一点,我不会感到惊讶。这可能吗?
这可能是一个“五金店”难题:我想要的零件被标记为不同的用途,除非我能猜出那个用途,否则我不知道该问什么。还有什么问题与此类似,而且已经解决了?就地脚注?
我知道平行文本,并排显示。这就是我现在所做的。这需要太多的眼球移动和对齐压力。如果 QWERTY 需要那么多的手指移动,那么现在每个人都会切换到 DVORAK 了。
我知道堆叠方框,以便将段落中的文本作为不可分割的实体流动。这可能是我初稿时所做的,但它浪费了空间。流动的交错文本可以相互借用空间,并且可以在需要时中断。
在某些应用中,交错的文本可能是几种语言,尽可能地同步翻译。有现成的工具(如“hunalign”)用于同步文本,因为这是人工智能语言学习的标准步骤。对于该应用,我肯定会得到一些不适合一行的块。我需要流独立流动。
答案1
是的,编码似乎是实用的方法。页面上的坐标必须在两个迭代器之间传输。
TikZ 允许在段落级别进行自由流文本交错的概念验证,并带有以下选项overlay
(一张图片在另一张图片之上):
原始交错:
添加(手动)间距后:
使用 Lua(或 expl3?)进行编码可能是同步句子开头的最简单方法。
平均能量损失
\documentclass{article}
\usepackage{xcolor}
\usepackage{fontspec}
\setmainfont{Noto Serif}
\setsansfont{Noto Sans}
\usepackage{tikz}
\usepackage{setspace}
\begin{document}
\doublespacing
\fbox{%
\begin{tikzpicture}[remember picture]
\node (a) [text width=0.98\textwidth, minimum width=0.98\textwidth]
{the objects in space and time are what first give rise to human reason.
Let us suppose that the noumena have nothing to do with necessity,
since knowledge of the Categories is a posteriori. Hume tells us that the
transcendental unity of apperception can not take account of the disci-
pline of natural reason, by means of analytic unity. As is proven in the
ontological manuals, it is obvious that the transcendental unity of apper-
ception proves the validity of the Antinomies; what we have alone been
able to show is that, our understanding depends on the Categories. It
remains a mystery why the Ideal stands in need of reason. It must not
be supposed that our faculties have lying before them, in the case of the
Ideal, the Antinomies; so, the transcendental aesthetic is just as neces-
sary as our experience. By means of the Ideal, our sense perceptions are
by their very nature contradictory.\\ \ \\ \ \\ \ };
\end{tikzpicture}\
}%fbox
\color{red}\sffamily
\begin{tikzpicture}[remember picture,overlay]
\node (b) at (a) [yshift=1.6ex,text width=0.98\textwidth, minimum width=0.98\textwidth]
{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus
lit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum
ravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulpu
ate a, magna. Donec vehicula augue eu neque. Pellentesque habitan
morbi tristique senectus et netus et malesuada fames ac turpis egestas
Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum
rna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat
nteger sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent ege
em vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, male
uada eu, pulvinar at, mollis ac, nulla. Curabitur auctor semper nulla
onec varius orci eget risus. Duis nibh mi, congue eu, accumsan eleifend
agittis quis, diam. Duis eget orci sit amet orci dignissim rutrum. Nam du
gula, fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi auctor
orem non justo. Nam lacus libero, pretium at, lobortis vitae, ultricies et
%ellus. Donec aliquet, tortor sed accumsan bibendum, erat ligula alique
%magna, vitae ornare odio metus a mi. Morbi ac orci et nisl hendrerit mol
%s. Suspendisse ut massa. Cras nec ante. Pellentesque a nulla. Cum sociis
%atoque penatibus et magnis dis parturient montes, nascetur ridiculus
%mus. Aliquam tincidunt urna. Nulla ullamcorper vestibulum turpis. Pel
%entesque cursus luctus mauris. Nulla malesuada porttitor diam. Donec
%elis erat, congue non, volutpat at, tincidunt tristique, libero. Vivamus
%iverra fermentum felis. Donec nonummy pellentesque ante. Phasel
%us adipiscing semper elit. Proin fermentum massa ac quam. Sed diam
};
\end{tikzpicture}
\color{black}\rmfamily
\newpage
\hfill Project Gutenberg: Jules Verne
\fbox{%
\begin{tikzpicture}[remember picture]
\node (c) [text width=0.98\textwidth, minimum width=0.98\textwidth]
{«Remontons-nous?
-- Non! Au contraire! Nous descendons!
-- Pis que cela, monsieur Cyrus! Nous tombons!
-- Pour Dieu! Jetez du lest!
-- Voilà le dernier sac vidé!
-- Le ballon se relève-t-il?
-- Non!
-- J'entends comme un clapotement de vagues!
-- La mer est sous la nacelle!
-- Elle ne doit pas être à cinq cents pieds de nous!»
Alors une voix puissante déchira l'air, et ces mots retentirent:
«Dehors tout ce qui pèse!... tout! et à la grâce de Dieu!» \\ \ };
\end{tikzpicture}
}%fbox
\color{red}\sffamily
\begin{tikzpicture}[remember picture,overlay]
\node (d) at (c) [yshift=1.5ex,text width=0.98\textwidth, minimum width=0.98\textwidth]
{“Are we rising again?” “No. On the contrary.” “Are we descending?”
“Worse than that, captain! we are falling!” “For Heaven’s sake heave out
the ballast!” “There! the last sack is empty!” “Does the balloon rise?”
“No!” “I hear a noise like the dashing of waves. The sea is below the
car! It cannot be more than 500 feet from us!” “Overboard with every
weight! ... everything!”};
\end{tikzpicture}
\color{black}\rmfamily
\newpage
\hfill Project Gutenberg: Jules Verne
\fbox{%
\begin{tikzpicture}[remember picture]
\node (e) [text width=0.98\textwidth, minimum width=0.98\textwidth]
{«Remontons-nous?
-- Non! Au contraire! Nous descendons!
-- Pis que cela, monsieur Cyrus! Nous tombons!
-- Pour Dieu! Jetez du lest!
\hspace{7em}-- Voilà le dernier sac vidé!
-- Le ballon se relève-t-il?
-- Non!
-- J'entends comme un clapotement de vagues!
-- La mer est sous la nacelle!
-- Elle ne doit pas être à cinq cents pieds de nous!»
Alors une voix puissante déchira l'air, et ces mots retentirent:
«Dehors tout ce qui pèse!... tout! et à la grâce de Dieu!» \\ \ };
\end{tikzpicture}
}%fbox
\color{red}\sffamily
\begin{tikzpicture}[remember picture,overlay]
\node (f) at (e) [yshift=-0.2ex,text width=0.98\textwidth, minimum width=0.98\textwidth]
{“Are we rising again?” “No. On the contrary.” “Are we descending?”
“Worse than that, captain! we are falling!” “For Heaven’s sake heave out
the ballast!” “There! the last sack is empty!” “Does the balloon rise?”
“No!” “I hear a noise like the dashing of waves. \hspace{4em}The sea is below the
car! \hspace{4.5em}It cannot be more than 500 feet from us!” \hspace{5em}\\ \ \\ \ “Overboard with every
weight! ... everything!”};
\end{tikzpicture}
\end{document}
附录
在 TikZ 中做了一些实验,段落左侧的句子看起来更具可读性,并且还会自动同步它们X-wise(显然)。也许可以使用数组/矩阵/网格结构作为插入句的起始位置。
上述内容的 MWE 部分宏观化:
\documentclass{article}
\usepackage{xcolor}
\usepackage{fontspec}
\setmainfont{Noto Serif}
\setsansfont{Noto Sans}
\usepackage{tikz}
\usepackage{setspace}
\usepackage{pgffor}
%============================================
\newcommand\doubleb[3]{%
\color{black}\rmfamily
\newpage
\fbox{%
\begin{tikzpicture}[remember picture]
\node (i) [text width=0.98\textwidth, minimum width=0.98\textwidth]
{#1\foreach \x in {1,...,#3}{\\ \ }};
\end{tikzpicture}
}%fbox
\color{red}\sffamily
\begin{tikzpicture}[remember picture,overlay]
\node (j) at (i) [,text width=0.98\textwidth, minimum width=0.98\textwidth]
{#2};
\end{tikzpicture}
}
%============================================
\begin{document}
\doublespacing
\doubleb{Or, au moment même où tant de catastrophes s'accomplissaient sur
terre et sur mer, un drame, non moins saisissant, se jouait dans
les airs bouleversés. \\
En effet, un ballon, porté comme une boule
au sommet d'une trombe, et pris dans le mouvement giratoire de la
colonne d'air, parcourait l'espace avec une vitesse de quatre-vingt-dix milles à l'heure, en tournant sur lui-même, comme s'il
eût été saisi par quelque maelström aérien. \\
Au-dessous de
l'appendice inférieur de ce ballon oscillait une nacelle, qui
contenait cinq passagers, à peine visibles au milieu de ces
épaisses vapeurs, mêlées d'eau pulvérisée, qui traînaient jusqu'à
la surface de l'Océan.}{But while so many catastrophes were taking place on land and at sea, a
drama not less exciting was being enacted in the agitated air.\\ \ \\
In fact, a balloon, as a ball might be carried on the summit of a
waterspout, had been taken into the circling movement of a column of
air and had traversed space at the rate of ninety miles an hour, turning
round and round as if seized by some aerial maelstrom.\\ \ \\
Beneath the lower point of the balloon swung a car, containing five
passengers, scarcely visible in the midst of the thick vapor mingled
with spray which hung over the surface of the ocean.\\ \ }{1}
\end{document}