- #1
Eclair_de_XII
- 1,083
- 91
- TL;DR Summary
- I have two files with the same line count. I want to read both of them in tandem and pass each line of said files as arguments to some two-parameter macro. I also want to print something on the line numbers specified by a different file I'm reading. How would I accomplish this?
style.sty:
\newcommand{\printNum}[2]{%
#1 #2%
}
\newread\readEng
\newread\readEsp
\newread\readLineNo
\newcount\myLineCount
\myLineCount=0
\newcommand{\printNumRow}{\loop\global\advance\myLineCount by 1\read\readEng to \Eng \read\readEsp to \Esp \printNum{\Eng}{\Esp}\ifnum\myLineCount=\linenum \read\readLineNo to \linenum \par The next line number to stop at is: \linenum\par\repeat}
main.tex:
\documentclass{minimal}
\usepackage{style}
\begin{document}
\input{body}
\end{document}
body.tex:
\openin\readLineNo=line-no.txt
\openin\readEng=english.txt
\openin\readEsp=spanish.txt
\read\readLineNo to \linenum
%\loop\advance\myLineCount by 1 \ifnum\myLineCount=\linenum \read\readLineNo to \linenum \par The next line number to stop at is: \linenum\par\else \read\readEng to \Eng \read\readEsp to \Esp \printNum{\Eng}{\Esp}\repeat
\printNumRow{}
\printNumRow{}
\printNumRow{}
\closein\readEng
\closein\readEsp
\closein\readLineNo
For some reason, the loop in line 8 of body.tex only runs the one time. I'm guessing the loop terminated because the \ifnum condition was satisfied. The \printNumRow{} calls were work-arounds to the problem. Can anyone think of a better one?