如何创建按段落对齐的 6 个平行文本,每页 3 个文本?

如何创建按段落对齐的 6 个平行文本,每页 3 个文本?

我想排版一个六语作品。每种语言占据一列,每页有 3 列。文本将按段落和标题对齐。

基本上,我想要的是类似这样的东西:

              Left Page                                Right Page
+--------------------------------------+ +--------------------------------------+
| Heading    | Тема 1     | Primero    | | Χαίρετε!   | 標題1       |    ספרות  |
| -------    | ---------  | ---------- | | ---------- | ---------- | ---------- |
| English t- | Це не рос- | No tengo   | | Πώς είσαι; | 其實我不知  |  פוליטיקה |
| ext taking | ійський т- | nada. Pero | | Καλό.      | 中國。      | לערך אינו |
| up 3 lines | екст а ук- | Juan tiene | |            | 我使用的是  | ציו ישראל |
|            | раїнській. |            | |            | 翻譯。      |    תבניות |
|            |            |            | |            |            |            |
| Heading 2  | Дуже довг- | Segundo    | | Ελληνική ε | 我喜歡牛肉!| בהיסטוריה |
| ---------- | ий Тема    | ---------- | | ίναι ωραία | ---------- | ---------- |
|            | ---------- |            | | ---------- |            |            |
| Text taki- | Круто!     | Estoy abu- | | Σ 'αγαπώ.  | 你喜歡牛肉  |   אם מפתח |
| ng up 2    |            | rrido.     | |            | 嗎?       |   קישורים |
|            |            |            | |            |            |    תקשורת |
+--------------------------------------+ +--------------------------------------+

我查看了平行库,但不知道该如何放入 3 列。我还查看了 parcolumns,但无法让两页文本对齐。

我该如何做这件事?

答案1

修订版本(自动分页控制):

与手动解决方案一样,使用 初始化“特殊表” \newspecialtable。同样,通过重复调用宏 向表中输入任意数量的行\sixby{}{}{}{}{}{},每行一次。但是,在这种情况下,如果某一行太大而无法推到下一页,则双页会在此处断开,完整的新行将移到下一个双页。

当所有行都通过 进入后\sixby,可以使用\finishspecialtable,清除最后的双页上的落后行。作为奖励,我为这个 MWE 添加了俄语和希腊语支持。 我希望我没有无意中咒骂或使用外国脏话,因为我只是从网站的其他页面复制了外文。

以防万一有人没能立即发现,表格列宽和整体最大文本高度已在此处(出于演示目的)分别重置为\def\colwidth{1in}\textheight=4in\relax。实际使用时应将它们重置为适当的值。

方法\printtabtoks来自 Herbert如何使用 `\whiledo` 以编程方式制作表格行?

已编辑以处理居中和引号。

\documentclass[]{article}
\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[greek,russian,english]{babel}
\usepackage{ifthen}
\usepackage{calc}

\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{1in}
\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\sixby[6]{%
  \stepcounter{entries}%
  \expandafter\def\csname entryX\roman{entries}Xa\endcsname{#1}%
  \expandafter\def\csname entryX\roman{entries}Xb\endcsname{\foreignlanguage{russian}{#2}}%
  \expandafter\def\csname entryX\roman{entries}Xc\endcsname{#3}%
  \expandafter\def\csname entryX\roman{entries}Xd\endcsname{\textgreek{#4}}%
  \expandafter\def\csname entryX\roman{entries}Xe\endcsname{#5}%
  \expandafter\def\csname entryX\roman{entries}Xf\endcsname{#6}%
  \synctabindex{entries}%
  \sbox{\pagerow}{\formatcol{a}\formatcol{b}\formatcol{c}\formatcol{d}\formatcol{e}\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 &
      \csname entryX\roman{tabindex}Xb\endcsname &
      \csname entryX\roman{tabindex}Xc\endcsname & 
      \vphantom{\formatcol{d}\formatcol{e}\formatcol{f}}
      \\%
      \hline%
    }%
  }%
  \begin{tabular}{|p{\colwidth}|p{\colwidth}|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}Xd\endcsname &
      \csname entryX\roman{tabindex}Xe\endcsname &
      \csname entryX\roman{tabindex}Xf\endcsname &
      \vphantom{\formatcol{a}\formatcol{b}\formatcol{c}}
      \\%
      \hline%
    }%
  }%
  \begin{tabular}{|p{\colwidth}|p{\colwidth}|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}

\textheight=4in\relax
\begin{document}
\centering
\newspecialtable
\sixby
  {Row 1: Title of {\centering \bfseries CENTERED\par} column 1 maybe a bit longer than column 3}%
  {Текст на русском языке}%
  {No tengo  nada. Pero Juan\begin{quote}\bfseries QUOTE\end{quote} tiene}%
  {Πώς είσαι Καλό.}%
  {while this is a test of a particularly extended line spanning a
    number of rows, more than all the others.  And I really mean more than all the others}%
  {T}
\sixby
  {Row 2: this is a test of a particularly extended line spanning a
    number of rows, more than all the others}%
  {Це не російський текст а українській.}%
  {Segundo}%
  {φύσις}%
  {Here is some text for this entry}%
  {column 6 entry maybe a bit longer than column 5}
\sixby
  {Row 3: this is a test of a longer line}%
  {Дуже довгий Тема}%
  {Estoy aburrido.}%
  {Και άλλο ελληνικό κείμενο}%
  {}%
  {column 6 entry maybe a bit longer than column 5}
\sixby
  {Row 4: this is a test of an extended rows}%
  {Круто!}%
  {Estoy aburrido.}%
  {ἀλλ' οὐ λέγουσι τὸ διὰ τί περὶ οὐδενός, οἷον διὰ}%
  {final text}%
  {column 6 entry maybe a bit longer than column 5}%
\sixby
  {Row 5: Title of column 1 maybe a bit longer than column 3}%
  {Текст на русском языке}%
  {No tengo  nada. Pero Juan tiene}%
  {Πώς είσαι Καλό.}%
  {while this is a test of a particularly extended line spanning a
    number of rows, more than all the others.  And I really mean more than all the others}%
  {T}
\sixby
  {Row 6: this is a test of a longer line}%
  {Це не російський текст а українській.}%
  {Segundo}%
  {φύσις}%
  {Here is some text for this entry}%
  {column 6 entry maybe a bit longer than column 5}
\sixby
  {Row 7: this is a test of an extended rows}%
  {Круто!}%
  {Estoy aburrido.}%
  {ἀλλ' οὐ λέγουσι τὸ διὰ τί περὶ οὐδενός, οἷον διὰ}%
  {final text}%
  {column 6 entry maybe a bit longer than column 5}%
\sixby
  {Row 8: Title of column 1 maybe a bit longer than column 3}%
  {Текст на русском языке}%
  {No tengo  nada. Pero Juan tiene}%
  {Πώς είσαι Καλό.}%
  {while this is a test of a particularly extended line spanning a
    number of rows, more than all the others.  And I really mean more than all the others}%
  {T}
\finishspecialtable
\end{document}

这里显示了前两页输出。MWE 输出了 6 页输出,演示了自动分页功能

在此处输入图片描述

在此处输入图片描述

原始解决方案(手动分页控制):

用 初始化一个“特殊表” \newspecialtable。然后,通过重复调用宏 向表中输入任意数量的行\sixby{}{}{}{}{}{},每行一次。输入完所有行后,使用\makespecialtable[],其中“行”是要打印的行数,以免超出分页符。多次调用\makespecialtable将继续处理行,直到表行用尽。

在这个 MWE 中,我使用了\sixby四次。然后我使用

\makespecialtable[3]
\makespecialtable

这样,rows(1-3)cols(1-3) 出现在第 1 页,rows(1-3)cols(4-6) 出现在第 2 页,row(4)cols(1-3) 出现在第 3 页,row(4)cols(4-6) 出现在第 4 页。

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{ifthen}

\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{1in}
\newcounter{sptstartrow}
\newcounter{sptendrow}
\newcounter{entries}

\newcommand\newspecialtable{%
  \setcounter{sptendrow}{0}%
  \setcounter{entries}{0}%
}

\makeatletter
\newcommand\sixby[6]{%
  \stepcounter{entries}%
  \expandafter\protected@edef\csname entryX\roman{entries}Xa\endcsname{#1}%
  \expandafter\protected@edef\csname entryX\roman{entries}Xb\endcsname{#2}%
  \expandafter\protected@edef\csname entryX\roman{entries}Xc\endcsname{#3}%
  \expandafter\protected@edef\csname entryX\roman{entries}Xd\endcsname{#4}%
  \expandafter\protected@edef\csname entryX\roman{entries}Xe\endcsname{#5}%
  \expandafter\protected@edef\csname entryX\roman{entries}Xf\endcsname{#6}%
}
\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 &
      \csname entryX\roman{tabindex}Xb\endcsname &
      \csname entryX\roman{tabindex}Xc\endcsname & 
      \vphantom{%
        \parbox[t]{\colwidth}{\csname entryX\roman{tabindex}Xd\endcsname\strut}%
        \parbox[t]{\colwidth}{\csname entryX\roman{tabindex}Xe\endcsname\strut}%
        \parbox[t]{\colwidth}{\csname entryX\roman{tabindex}Xf\endcsname\strut}%
      }
      \\%
      \hline%
    }%
  }%
  \begin{tabular}{|p{\colwidth}|p{\colwidth}|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}Xd\endcsname &
      \csname entryX\roman{tabindex}Xe\endcsname &
      \csname entryX\roman{tabindex}Xf\endcsname &
      \vphantom{%
        \parbox[t]{\colwidth}{\csname entryX\roman{tabindex}Xa\endcsname\strut}%
        \parbox[t]{\colwidth}{\csname entryX\roman{tabindex}Xb\endcsname\strut}%
        \parbox[t]{\colwidth}{\csname entryX\roman{tabindex}Xc\endcsname\strut}%
      }%
      \\%
      \hline%
    }%
  }%
  \begin{tabular}{|p{\colwidth}|p{\colwidth}|p{\colwidth}|@{\extracolsep{-\tabcolsep}}l}%
   \hline%
   \printtabtoks%
  \end{tabular}%
}

\begin{document}
\newspecialtable
\sixby
  {Row 1: Title of column 1 maybe a bit longer than column 3}%
  {this is a test of a longer line}%
  {BC}%
  {while this is a test of a particularly extended line spanning a
    number of rows, more than all the others.  And I really mean more than all the others}%
  {xcxcx}%
  {T}
\sixby
  {Row 2: this is a test of a longer line}%
  {Here is some text for this entry}%
  {while this is a test of a particularly extended line spanning a
    number of rows, more than all the others}%
  {F}%
  {T}%
  {column 6 entry maybe a bit longer than column 5}
\sixby
  {Row 3: this is a test of a longer line}%
  {BC}%
  {F}%
  {T}%
  {while this is a test of a particularly extended line spanning a
    number of rows, more than all the others}%
  {column 6 entry maybe a bit longer than column 5}
\sixby
  {Row 4: this is a test of an extended rows}%
  {x}%
  {a word}%
  {column 6 entry maybe a bit longer than column 5}
  {final line}%
  {}%
\centering
\makespecialtable[3]% Print 3 rows of the table (so as not to exceed page boundary)
\makespecialtable
\end{document}

在此处输入图片描述

在此处输入图片描述

答案2

这里通过带有 的表格环境来解决这个问题0.3\linewidth,顶部对齐。由于您的输出还需要垂直对齐第二个标题,因此parbox使用 ,高度为 3cm。

\newcommand*{\heading}[1]{#1\\\hline}
\newcommand*{\body}[1]{\parbox[t][3cm]{0.3\textwidth}{#1}\\}
%------------------------------------------------
\begin{document}
\begin{tabular}[t]{|p{0.3\linewidth}}\hline  
\heading{Heading 1}
\body{English text taking up 3 lines \\ and More}%
\heading{Heading 2}
\body{Continue as usual.}\hline
\end{tabular}%
%------------------------------------------------                               
\begin{tabular}[t]{|p{0.3\linewidth}}\hline 
\heading{Title 1}
\body{The is the text filling up the second column. The is the text filling up the second column.}%
\heading{Title 2}
\body{Continue as usual.}\hline
\end{tabular}%
%-----------------------------------------------                              
\begin{tabular}[t]{|p{0.3\linewidth}|}\hline
\heading{Primero 1}
\body{This is the text filling the third column. This is the text filling the third column. 
This is the text filling the third column.}%
\heading{Primero 2}
\body{Continue as usual.}\hline
\end{tabular}                               
\end{document}

\parbox没有使用任何特定的包。这里可以更改高度为3cm。\textwidth例如,可以更改为\linewidth。宏(标题和正文)旨在让用户摆脱 LaTeX 设置的束缚,并可根据您的需要进行修改。

在此处输入图片描述

已更新:此内容将满足 OP 的愿望。使用 Parallel 包,灵感来自 John Kormylo。

\documentclass[]{book}
\usepackage[margin=1in]{geometry}
\usepackage{parallel}

\newcommand*{\heading}[1]{{\strut #1\strut}}     
\newcommand*{\body}[1]{{\vspace{0pt}\strut #1\strut \par}}
\begin{document}
\begin{Parallel}[p]{}{}
\ParallelLText{
\begin{tabular}[t]{|p{0.3\textwidth}|p{0.3\textwidth}|p{0.3\textwidth}|} \hline
\heading{Heading 1} &
\heading{Heading 2} & 
\heading{Heading 3}  \\ \hline
\body{English text taking up 1 lines  and More} & 
\body{English text taking up 3 lines  and More, English text taking up 3 lines  and More} &
\body{English text taking up 4 lines  and More. English text taking up 4 lines  and More. English text taking up 4 lines  and More} \\ 
\heading{Title 1} &
\heading{Title 2 and more and more and more and more} & 
\heading{Title 3}  \\ \hline
\body{English text taking up 3 lines  and More} & 
\body{Continue as usual.} &
\body{Continue as usual.} \\ \hline
\end{tabular}
}
\ParallelRText{
\begin{tabular}[t]{|p{0.3\textwidth}|p{0.3\textwidth}|p{0.3\textwidth}|} \hline
\heading{Title 1} &
\heading{Title 2 and more and more and more and more} & 
\heading{Title 3}  \\ \hline
\body{English text taking up 3 lines  and More} & 
\body{Continue as usual.} &
\body{Continue as usual.} \\ 
\heading{Heading 1} &
\heading{Heading 2} & 
\heading{Heading }  \\ \hline
\body{English text taking up 3 lines  and More} & 
\body{Continue as usual.} &
\body{Continue as usual.} \\ \hline
\end{tabular}
}
\end{Parallel}
\end{document}

在此处输入图片描述在此处输入图片描述

答案3

根据之前的答案(https://tex.stackexchange.com/a/131394/51244)。一种改进方法是使用不同宽度的列作为表格。对于多张双页表格,在每一页上都显示列标题(即第一行)的提示是很有趣的。

这里提出了这个解决方案:http://blog.m123.be/pluxml/index.php?article16/howto-ecrire-un-tableaux-sur-plusieurs-double-page-en-latex

相关内容