似乎不可能以下列方式组合\obeyspaces
和:\read
\newread\myread
\openin\myread=myfile.txt
\obeyspaces % Deleting this line removes the error
\read\myread to \myinput
\myinput
\closein\myread
这\tracingall
对我理解问题没有什么帮助。
答案1
您只需保留\read
语法周围的正常空格:
\newread\myread
\def\doread#1#2{\immediate\read#1 to #2}
\immediate\openin\myread=myfile.txt
{\obeyspaces
\doread\myread\myinput\immediate\write20{\myinput}%
\doread\myread\myinput\immediate\write20{\myinput}%
\doread\myread\myinput\immediate\write20{\myinput}%
\doread\myread\myinput\immediate\write20{\myinput}%
}
\immediate\closein\myread
\bye
00
1 1
2 2
3 3
生产
This is TeX, Version 3.1415926 (TeX Live 2012)
(./rd55.tex
00
1 1
2 2
3 3
)
No pages of output.