For a critical edition in two languages, my Main.tex file has a loop that:

  1. reads a line from first source file
  2. reads a line from second source file
  3. outputs the lines with the \chunks command
  4. uses \ifeof0 to control \loop by detecting EOF of first source file

A better \loop would check EOF for both source files. However, TeXstudio will not compile \ifeof0 and \ifeof1 in the loop condition. Any advice?

Source files and example code follow.

Please assume source files with these contents.


This is paragraph 1 from LeftPageParagraphs.tex file.

This is paragraph 2 from LeftPageParagraphs.tex file.


This is paragraph 1 from RightPageParagraphs.tex file.

This is paragraph 2 from RightPageParagraphs.tex file.

An annotated minimum working example of the problem:

% Test: read lines from files.


\usepackage{paracol}  % Parallel columns package

% The \chunks command outputs two parallel paragraphs 
% to left and right columns on facing pages.


    % Algorithm:
    % Read a line (a paragraph) from input stream 0.
    % Read a line (a paragraph) from input stream 1.
    % Output line to left column on left page.
    % Output line to right column on right page.    
    % Detect end-of-file in input stream 0.

    % PASS with condition: \ifeof0
    % FAIL with condition: { \( \ifeof0 \and \ifeof1 \) }
    % ERROR: Incomplete \ifeof; all text was ignored after line 49.
    % Open files in input streams 0 and 1.
    \openin0 = LeftPageParagraphs
    \openin1 = RightPageParagraphs
            \read0 to \inputL  
            \read1 to \inputR
        \( \ifeof0 \and \ifeof1 \) % <-- ERROR

    % Close files in input streams 0 and 1.

1 Answer 1



\( \ifeof0 \and \ifeof1 \) 

\( and \) are commands for typesetting math, not for evaluating logical expressions

\and is a command used by \maketitle for separating authors

\ifeof0 accesses stream 0 which is reserved by LaTeX as part of \IFFileExists , filecontents and other file related constructs.

replace streams 0 and 1 by two allocated streams


and combine the tests for example by having a new \if.. command used in the loop



Which will continue the loop until both streams hit eof.

  • Perhaps clarify that \(, \) and \and can be used for logical statements only in the first argument of \ifthenelse?
    – Joseph Wright
    Feb 2, 2022 at 10:34
  • 5
    @JosephWright I try to forget about \ifthenelse Feb 2, 2022 at 10:38
  • @JosephWright ah I just now saw the related question on meta Feb 2, 2022 at 17:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .