0

If I want to use the \newlinechar and \endlinechar primitives to output the position information at the beginning and end of each line of text, what should I do?

6
  • 1
    \newlinechar and \endlinechar are internal registers, they have no role whatsoever when typesetting, other than making TeX aware of the integer stored in them (and \newlinechar is only relevant with \write).
    – egreg
    Commented Nov 23, 2021 at 9:09
  • 1
    I think you need to be clearer what your intended output is. You seem to be asking about lines in the typeset output but neither of those primitives is related to that. \newlinechar makes newlines in \write and \typeout etc. \endlinechar is the character added to each line of the source Commented Nov 23, 2021 at 9:11
  • I want to know the start and end coordinates of each line in the pdf generated by latex rendering. I hope to automatically generate line coordinate information for all text lines in the entire pdf by redefining some related primitives.
    – happy
    Commented Nov 23, 2021 at 9:21
  • you can not really get that information from classical tex commands Commented Nov 23, 2021 at 9:24
  • Because I have learned that by redefining \everypar, I can output some content at the beginning of each paragraph, so I am exploring whether there are corresponding primitives that can help me get position information at the beginning and end of each line.
    – happy
    Commented Nov 23, 2021 at 9:32

1 Answer 1

1

You seem to be asking about lines in the typeset output but neither of those primitives is related to that. \newlinechar makes newlines in \write and \typeout etc. \endlinechar is the character added to each line of the source.

You can use the latex paragraph hooks (better than using everypar directly) to get the start and end of the paragraph so if you assume normal text and even line spacing you can guess the line positions but if any line is over-large and line spacing is disturbed you can not access the line positions from TeX.

1
  • You might add that "breaking paragraphs into lines" is rather dynamic, and a very small change in a paragraph can change where lines start and end, except at the beginning and end of the paragraph itself. Commented Jan 10, 2023 at 3:49

You must log in to answer this question.

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