I want to use subfile within a loop to add new pages to a document, depending on the number of lines in a .txt file.
The .txt may look like this:
0001
0002
0003
The .tex Subfiles are A0001.tex, A0002.tex A0003.tex
My code:
\documentclass{article}
\usepackage{subfiles}
\usepackage{forloop}
\begin{document}%
%
\newread\file%
\openin\file=mytextfile.txt%
\loop\unless\ifeof\file%
\read\file to\linecontent%
\subfile{A\linecontent}
\newpage%
\repeat%
\closein\file%
\end{document}
I get this error messages for codeline 22 (\repeat), despite that the .pdf is created and looks correct.
Paragraph ended before @iinput was complete.
Extra }, or forgotten \endgroup. @import ...er #1\expandafter {\import@path@file }
If i change the subfile input to only one subfile (A0001), there is no error but it adds 4 ! new pages as if there where 4 lines in the .txt file.
\subfile{A0001}
I think im missing some small detail, but i really dont know what.
\subfile
for example looks forA0001 .tex
, which is not available. I am currently looking for a solution for this problem.subfiles
package. Replacing\subfiles
by\input
shows the same issue, which is related to the loop not terminating properly.