Yes, TeX can read a line in a file and use it as input. The example working code below now implements the accepted answer from Willie Wong.
For the new user: "\inputL" and "\inputR" are not TeX commands. Mr. Wong's answer states that they are macros.
A TeX macro is something like a variable that is declared when the macro name is first used, and a string value is read into it. It is something like a function because when the macro name is used a second time, when it will return the string value.
Source files, desired output, and example code follow.
Please assume source files with these contents.
LeftPageParagraphs.tex:
This is paragraph 1 from LeftPageParagraphs.tex file.
This is paragraph 2 from LeftPageParagraphs.tex file.
RightPageParagraphs.tex:
This is paragraph 1 from RightPageParagraphs.tex file.
This is paragraph 2 from RightPageParagraphs.tex file.
Desired output document should have a left page and a right page.
Left page should have read and input one paragraph:
This is paragraph 1 from LeftPageParagraphs.tex file.
Right page should have read and input one paragraph:
This is paragraph 1 from RightPageParagraphs.tex file.
An annotated minimum working example of the solution:
\documentclass[openany]{book}
\usepackage{paracol} % Parallel columns package
% The \chunks command outputs a pair of parallel paragraphs to
% the left and right columns on facing pages.
\newcommand\chunks[2]{%
\begin{leftcolumn*}
{#1}%
\end{leftcolumn*}%
\begin{rightcolumn}
{#2}%
\end{rightcolumn}%
}
\begin{document}
% Open *.tex files in input streams 0 and 1).
\openin0 = {LeftPageParagraphs}
\openin1 = {RightPageParagraphs}
\begin{paracol}[1]*{2} % Open parallel columns "environment".
\read0 to \inputL % <-- Reads first line from first file.
\read1 to \inputR % <-- Reads first line from second file.
\chunks % <-- Pass: Adds line from each file as paragraph.
{\inputL}
{\inputR}
\end{paracol}
% Close files (input streams 0 and 1).
\closein0
\closein1
\end{document}
Best Answer
(Converted from comment)
The command
\read<stream> to<macro>
stores the next line of input from<stream>
and stores it as<macro>
.So if the file you are reading starts
Then
will have the same effect as
Hence, to accomplish what you want, you probably should: