2

TeX will insert \endlinechar at the end of line.

If the value of \endlinechar is negative or greater than 255, no character is appended, and the effect is as if every line ends with %.

\def\endlinechar{\char256}
hello

hello2
\bye

produces

enter image description here

Even if the \endlinechar has been changed to greater than 255, the character is still append to the end of the line, which cause the effect as \par at the end of the line. What is the reason?

8
  • 4
    You've not set \endlinechar-the-primitive, you've created a macro of the same name: you want \endlinechar=256 %
    – Joseph Wright
    Nov 29, 2023 at 12:50
  • @JosephWright What is the meaning of \endlinechar=256. From what page I should watch to learn this style of definition?
    – Y. zeng
    Nov 29, 2023 at 12:59
  • The primitive integer parameters are listed on pp. 272-273.
    – campa
    Nov 29, 2023 at 13:25
  • @campa God.This book has such a big jump.
    – Y. zeng
    Nov 29, 2023 at 13:29
  • 1
    @Y.zeng As we've said many times, you need to read the book several times and skip over the harder parts until you are comfortable
    – Joseph Wright
    Nov 29, 2023 at 13:54

1 Answer 1

6

\endlinechar is an internal integer register. Assigning it a value is done in the standard way, namely

\endlinechar=<integer>

just like

\count255=42

In Knuth TeX or pdftex you can assign it the value 256, which would result in nothing being appended to a record after discarding the OS specific end-of-record signal and trailing characters with ASCII code 32.

If you do \def\endlinechar{whatever}, you just lose the ability to change the value of the internal register.

Note. XeTeX behaves like Knuth TeX as far as \endlinechar is concerned, so only values between 0 and 255 (inclusive) will result in some character being appended. LuaTeX lowers the upper bound to 127.

You should have been surprised that the code doesn't raise errors. Indeed, your \endlinechar macro is never used, otherwise \char256 would have raised an error (in Knuth TeX or pdftex).

You must log in to answer this question.

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