5

Is it possible to import two tex files with \input and to have the content of the one file be always on the left page facing the content of the other file being always on the right? The page numbers should go on continuously 1, 2, 3, 4, ...

(Actually I guess that this is not so easy to be achieved.)

I imagine something like this:

%!TEX TS-program = lualatexmk
\documentclass{scrbook}
\begin{document}

\input[left]{file_A.tex}
\input[right]{file_B.tex}

\end{document}

Both files would just consist of simple data such as

\chapter{Chapter}
Text.
\section{Section}
Text. ...

Nonetheless both files will be long and contain several pages worth of text. In other words, I would have two long files file_A.tex and file_B.tex and latex fills me the left page consecutively with the contents of A and the right pages consecutively with the contents of B.

This being said, I don't mind (and in fact would prefer!) to cut the contents of the two files in page-size chunks by manually using \pagebreak several times at appropriate places within each file.

  • I guess you could typeset them both on their own and increment the page counter by 2 on each page, then splice the pdfs together? – Juri Robl Jan 27 '15 at 07:52
  • Yes, I thought of this. This is one -- potentially laborious -- way to do it. – ClintEastwood Jan 27 '15 at 07:54
  • why not using eledpar? – Maïeul Jan 28 '15 at 16:42
  • actually, because I am looking for an alternative to eledmac/eledpar, as I have been unable to overcome my problems with these packages for three years. – ClintEastwood Jan 28 '15 at 19:11
  • what are the problems? – Maïeul Jan 29 '15 at 17:27
  • @Maïeul We have been in contact about some of these a few months back, if you remember. Especially the way how eledpar creates page breaks automatically is unsatisfying in my case, i.e., the text on the left is not synchronised with the text on the right. It's just not good enough to be published that way, although some features of eledpar are just really cool. Since eledpar automatises many thinks (e.g., page breaks and so on ) and does not allow the user to intervene, I am now looking for a less automatic and more hands-on approach - even if that is at the expense of the cool features. – ClintEastwood Jan 30 '15 at 06:50
  • eledpar has now a manual page break system. – Maïeul Jan 30 '15 at 10:22
  • @Maïeul do you mean \ledpb? I tried it but could not make it work. I'd be glad if you could show me here in an answer how I can use eledpar with manual page breaks on both pages. just a quick minimal example would suffice. you could also do it here: http://tex.stackexchange.com/a/147018/12277 – ClintEastwood Jan 30 '15 at 11:32
  • I should need some example in which \ledpb doesn't worrk to understand. All my test with \ledpb were working. – Maïeul Jan 30 '15 at 13:07
  • @Maïeul maybe it would then help if you showed as an answer to this questions how \ledpb works – ClintEastwood Jan 31 '15 at 07:54
  • 1
    it's work like explained in this handbook. See this MWE http://pastebin.fr/38373 – Maïeul Jan 31 '15 at 10:20
  • @Maïeul : ok I see this works for Latin text. Thx. Still I am looking for alternatives. – ClintEastwood Feb 01 '15 at 15:27
  • non only latin text... – Maïeul Feb 01 '15 at 16:54

1 Answers1

1

You can probably arrange to store each page in a box instead of shipping it out, and then sorting the boxes at the end, something like this:

enter image description here

\documentclass[openany]{scrbook}

\newcount\zzz
\newif\ifdone
\let\zzshipout\shipout
\makeatletter
\def\shipout\vbox#1{%
\edef\x{\noexpand\typeout{page \thepage\space is box \the\zzz}}\x
\global\setbox\zzz\vbox{#1}%
\global\advance\zzz1 %
\stepcounter{page}%
}

\begin{document}

\clearpage
\zzz=5001\setcounter{page}{1}
\input{file_A.tex}

\clearpage
\zzz=6001\setcounter{page}{2}
\input{file_B.tex}
\clearpage

\typeout{===========}

\makeatletter
\begingroup 
  \let \protect \noexpand
  \@resetactivechars
  \@parboxrestore
 \global\c@page=1
\loop
\ifvoid\numexpr5000+\c@page\relax
  \ifvoid\numexpr6000+\c@page\relax
    \donetrue
  \else
    \zzshipout\vbox{\hbox{blank A}}%
    \zzshipout\box\numexpr6000+\c@page
  \fi
\else
  \zzshipout\box\numexpr5000+\c@page
  \ifvoid\numexpr6000+\c@page\relax
    \zzshipout\vbox{\hbox{blank B}}%
  \else
    \zzshipout\box\numexpr6000+\c@page
  \fi
\fi
\ifdone\else
\global\advance\c@page1 %
\repeat

\endgroup
\end{document}
David Carlisle
  • 757,742