这个问题是我之前的问题。在此 MWE 中,注释/直行注释和翻译(左侧的“非 Lipsum”文本)位于单独的 parboxes 中,然后在同一页面上垂直对齐。包ifoddpage
将翻译保存在页面内部:
上图的 MWE:
\documentclass{book}
\usepackage{microtype}
\usepackage{expex}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\newfontfamily\hebrewfont[Script=Hebrew]{FrankRuehl}
\newfontfamily\englishfont{Times New Roman}
\lingset{
everygla=\Large,
everyglb=\scriptsize\englishfont,
everyglc=\scriptsize\englishfont,
glwordalign=center,
glhangindent=0em,
glrightskip=0pt,
}
\usepackage{ifoddpage}
\newcommand{\swapboxes}[2]% #1 = wide text, #2 = narrow text
{\noindent\makebox[\textwidth]{\checkoddpage
\ifoddpageoroneside
\parbox[t]{.71\textwidth}{#1}\hfill\parbox[t]{.26\textwidth}{#2}%
\else
\parbox[t]{.26\textwidth}{#2}\hfill\parbox[t]{.71\textwidth}{#1}%
\fi}}% this \swapboxes macro forces the parboxes to switch sides every odd page
\begin{document}
\swapboxes{\exdisplay\begingl
\gla אאאא בבבב גגגג דדדד אא בב גג דד אאאא בב גגגג דדד אאאא בבבבב גג דדדד אא בבבב גגגגג דדד אאאא בבבב גגגג דדדד אא בב גג דד אאאא //
\glb aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa //
\glc aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa //
\endgl \xe}{\exdisplay\footnotesize\textenglish{Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is the end} \xe}
\swapboxes{\exdisplay\begingl
\gla אאאא בבבב גגגג דדדד אא בב גג דד אאאא בב גגגג דדד אאאא בבבבב גג דדדד אא בבבב גגגגג דדד אאאא בבבב גגגג דדדד אא בב גג דד אאאא //
\glb aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa //
\glc aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa //
\endgl \xe}{\exdisplay\footnotesize\textenglish{Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is the end} \xe}
\swapboxes{\exdisplay\begingl
\gla אאאא בבבב גגגג דדדד אא בב גג דד אאאא בב גגגג דדד אאאא בבבבב גג דדדד אא בבבב גגגגג דדד אאאא בבבב גגגג דדדד אא בב גג דד אאאא //
\glb aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa //
\glc aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa //
\endgl \xe}{\exdisplay\footnotesize\textenglish{Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is the end} \xe}
\end{document}
为什么我需要你的帮助:
我希望新的输出看起来更像下图,其中注释/直译总是在翻译的对页上(注释和翻译都占据整页宽度),并且对文档的其余部分继续这样做:
parbox
我对和非版本都持开放态度parbox
。我研究过reledmac/reledpar
,但它们似乎与 不兼容expex
。该parallel
软件包可能是一种选择,但我不确定它是否对我想要做的事情非常用户友好,我想要做的事情是生成多页类似于上述示例的文本,理想情况下,我不想要处理分页问题。
更新:
基于这个帖子,我创建了以下解决方案。它不使用parallel
。我不太理解它,但它似乎有效。我有大量垂直填充,我很想摆脱它。
梅威瑟:
\documentclass{book}
\usepackage{expex}
\usepackage{polyglossia}
\usepackage{fontenc}
\setdefaultlanguage{english}
\setotherlanguage{hebrew}
\newfontfamily\hebrewfont[Script=Hebrew]{FrankRuehl}
\newfontfamily\englishfont{Times New Roman}
\lingset{
everygla=\Large, %some options are normalsize,large, Large, LARGE
everyglb=\scriptsize\englishfont\it,
everyglc=\scriptsize\englishfont,
glwordalign=center,
glhangindent=0em,
glrightskip=0pt
}
%here begins the code from https://tex.stackexchange.com/a/172887/121944
\usepackage{ifthen}
\usepackage{calc}
\usepackage{lipsum}
\makeatletter
\newcounter{tabindex}
\newtoks\@tabtoks
\newcommand\addtabtoks[1]{%
\@tabtoks\expandafter{\the\@tabtoks\stepcounter{tabindex}#1}}
\newcommand*\resettabtoks{\@tabtoks{}}
\newcommand*\synctabindex[1]{\setcounter{tabindex}{\value{#1}}}
\newcommand*\printtabtoks{\the\@tabtoks}
\makeatother
\def\colwidth{\textwidth}
\newcounter{sptstartrow}
\newcounter{sptendrow}
\newcounter{entries}
\newcounter{pagerows}
\newlength\CurrentTableHeight
\newlength\CurrentRowHeight
\newsavebox\pagerow
\newcommand\newspecialtable{%
\setcounter{sptendrow}{0}%
\setcounter{entries}{0}%
\setcounter{pagerows}{0}%
\setlength\CurrentTableHeight{0pt}%
}
\makeatletter
\newcommand\twoby[2]{%
\stepcounter{entries}%
\expandafter\def\csname entryX\roman{entries}Xa\endcsname{#1}%
\expandafter\def\csname entryX\roman{entries}Xf\endcsname{#2}%
\synctabindex{entries}%
\sbox{\pagerow}{\formatcol{a}\formatcol{f}}%
\setlength\CurrentRowHeight{\ht\pagerow+\dp\pagerow}%
\addtolength\CurrentTableHeight{\CurrentRowHeight}%
\ifdim\CurrentTableHeight>\textheight %
\makespecialtable[\thepagerows]%
\setcounter{pagerows}{0}%
\setlength\CurrentTableHeight{\CurrentRowHeight}%
\else\fi%
\stepcounter{pagerows}%
}
\makeatother
\newcounter{index}
\newcommand\makespecialtable[1][\theentries]{%
\setcounter{sptstartrow}{\thesptendrow}%
\addtocounter{sptendrow}{#1}%
\ifthenelse{\thesptendrow > \theentries}{\setcounter{sptendrow}{\theentries}}{}%
\clearpage
\setcounter{index}{\thesptstartrow}%
\synctabindex{index}
\resettabtoks%
\whiledo{\theindex < \thesptendrow}{%
\stepcounter{index}%
\addtabtoks{%
\csname entryX\roman{tabindex}Xa\endcsname &
\vphantom{\formatcol{f}}
\\%
\hline%
}%
}%
\begin{tabular}{|p{\colwidth}|@{\extracolsep{-\tabcolsep}}l}%
\hline%
\printtabtoks%
\end{tabular}%
\clearpage
\setcounter{index}{\thesptstartrow}%
\synctabindex{index}
\resettabtoks%
\whiledo{\theindex < \thesptendrow}{%
\stepcounter{index}%
\addtabtoks{%
\csname entryX\roman{tabindex}Xf\endcsname &
\vphantom{\formatcol{a}}
\\%
\hline%
}%
}%
\begin{tabular}{|p{\colwidth}|@{\extracolsep{-\tabcolsep}}l}%
\hline%
\printtabtoks%
\end{tabular}%
}
\newcommand\formatcol[1]{%
\parbox[t]{\colwidth}{\csname entryX\roman{tabindex}X#1\endcsname\strut}%
}
\newcommand\finishspecialtable{\makespecialtable}
\begin{document}
\centering
\newspecialtable
\twoby
{\exdisplay\footnotesize\textenglish{Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is the end} \xe}%
{\exdisplay\begingl
\gla אאאא בבבב גגגג דדדד אא בב גג דד אאאא בב גגגג דדד אאאא בבבבב גג דדדד אא בבבב גגגגג דדד //
\glb aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd //
\glc aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd //
\endgl \xe}%
\twoby
{\exdisplay\footnotesize\textenglish{Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is the end} \xe}%
{\exdisplay\begingl
\gla אאאא בבבב גגגג דדדד אא בב גג דד אאאא בב גגגג דדד אאאא בבבבב גג דדדד אא בבבב גגגגג דדד אאאא בבבב גגגג דדדד אא בב גג דד אאאא אאאא בבבב גגגג דדדד אא בב גג דד אאאא בב גגגג דדד אאאא בבבבב גג דדדד אא בבבב גגגגג דדד אאאא בבבב גגגג דדדד //
\glb aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd //
\glc aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd //
\endgl \xe}%
\twoby
{\exdisplay\footnotesize\textenglish{Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is the end} \xe}%
{\exdisplay\begingl
\gla אאאא בבבב גגגג דדדד אא בב גג דד אאאא בב גגגג דדד אאאא בבבבב גג דדדד אא בבבב גגגגג דדד אאאא בבבב גגגג דדדד אא בב גג דד אאאא //
\glb aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa //
\glc aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa //
\endgl \xe}%
\finishspecialtable
\end{document}
输出:
答案1
这是一个有趣的排版问题。当我问同样(或非常相似)的问题时,我找不到解决方案在2011年,但我认为现在我有更好的办法了。这需要一点工作量,但都可以编写脚本,而且不需要手动分页。
这个想法如下:
- 仅排版奇数页(希伯来语),页码为奇数,并且每个希伯来语部分的高度至少与相应的英语部分相同。
- 仅排版偶数(英语)页,页码为偶数,并且每个英语部分的高度至少与相应的希伯来语部分相同。
- 合并生成的 PDF 文件,使两个 PDF 文件的页面交错。
以下是结果的一对对页:
这是odd.tex
:
\newif\ifhebrewpage
\hebrewpagetrue
\input common
这是even.tex
:
\newif\ifhebrewpage
\hebrewpagefalse
\input common
大部分代码如下common.tex
:
\documentclass{book}
\usepackage{expex}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguage{hebrew}
\newfontfamily\hebrewfont[Script=Hebrew]{Noto Sans Hebrew}
\newfontfamily\englishfont{Times New Roman}
\lingset{
everygla=\Large,
everyglb=\scriptsize\englishfont,
everyglc=\scriptsize\englishfont,
glwordalign=center,
glhangindent=0em,
glrightskip=0pt,
}
% Skips page numbers by 2 each time, so that every page is odd or every page is even.
% https://tex.stackexchange.com/a/238887/48
\makeatletter
\let\old@outputpage\@outputpage
\def\@outputpage{\old@outputpage\stepcounter{page}}
\makeatother
% Typeset either English or Hebrew text, with at least as much height as the "other" text
\newsavebox\HebrewBox
\newsavebox\EnglishBox
\newcommand{\parallelPair}[2]
{
\savebox\HebrewBox[\textwidth]{\parbox[t]{\textwidth}{#1}}
\savebox\EnglishBox[\textwidth]{\parbox[t]{\textwidth}{#2}}
\noindent
\ifhebrewpage
\usebox\HebrewBox\vphantom{\usebox\EnglishBox}
\else
\usebox\EnglishBox\vphantom{\usebox\HebrewBox}
\fi
}
% Just some test text to avoid repetition; in the real document you'd have sets of \parallelPair{...}{...} and not this \testpair
\newcommand{\testpair}{
\parallelPair{\exdisplay\begingl
\gla אאאא בבבב גגגג דדדד אא בב גג דד אאאא בב גגגג דדד אאאא בבבבב גג דדדד אא בבבב גגגגג דדד אאאא בבבב גגגג דדדד אא בב גג דד אאאא //
\glb aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa //
\glc aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa bbb ggg ddd aaaa //
\endgl \xe}{\exdisplay\strut\footnotesize\textenglish{Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is some non lipsum text to fill up this space Here is the end} \xe}
}
\begin{document}
\ifhebrewpage
\null\newpage % Page 1 will be blank
\else
\stepcounter{page} % Want even pages
\fi
\testpair
\testpair
\testpair
\testpair
\testpair
\end{document}
要拆分和合并 PDF,我使用poppler utils 中的pdfunite
和pdfseparate
(您也可以使用pdftk
,甚至可以使用 LaTeX 本身……):
xelatex odd.tex
xelatex even.tex
pdfseparate odd.pdf "pages_%03d_A.pdf"
pdfseparate even.pdf "pages_%03d_B.pdf"
pdfunite pages_00*.pdf out.pdf
您在上图中看到的是两张相对的页面out.pdf
。
我发现这是可行的,尽管事情并不完美:
- 对面的段落在基线处没有完全对齐,我不知道为什么(没有深入研究)。
- 我们坚持认为,每对平行文字都应完全适合各自的页面。这可能是一个棘手的分页问题,因此您可能不希望
\raggedbottom
(最好不要)某些文字对包含的高度超过单个页面所能容纳的文字。
(有趣的是,从核心上讲,这个parallel
包似乎在做类似的事情,但不知何故它工作起来并不方便。)