We handle arbitrary user input and attempt to programmatically generate LaTeX for compilation. One issue we sometimes run into is users writing very long lines (paragraphs) of text, resulting in an error:
! Unable to read an entire line
The sensible — but potentially naïve — solution seems to be for us to set some line length limit, and just break the line ourselves on a space. For example, given:
foo bar baz
and a line limit of 5 characters, we'd end up with:
foo bar
baz
...which should just render the same, since spaces and newlines are interchangeable.
This even works fine for macros:
\textit{foo
bar baz}
However, does this work in all cases? Are there any instances where a newline character would be treated differently to a space character? Or are they perfectly interchangeable?
buf_sizein TeX Live is 200000, so it takes a very long line to get that error. – egreg Jan 05 '21 at 08:49\verb|foo bar baz|with a newline would error. – Ulrike Fischer Jan 05 '21 at 08:54