以防有人读到这么旧的帖子,TeX 在将文本排成段落时并不知道分页符会在哪里,所以除非你指的是段落内部的行,否则没有简单的方法获取行号。
如果你知道你的段落跨越了页面边界,那么获取行号的潜在方法涉及在页面的正确位置放置适当的位置标记 \write,这会写入 .parlocs 文件。在作业结束时,找到该值与上一页/栏起始位置之间的差值,并将该数字除以基线大小。
然而,数学计算会因章节标题、图片或行距变化等因素而变得复杂,而且它基于上一次运行的结果,因此结果可能是错误的。
这基本上是如何计算图片偏移切口的一种更复杂的版本(它们只需要担心段落内的计数),那里的结果是……通常正确,但并不总是如此。
关于链接,我不确定上述内容或文档是否清晰:属性不需要附加到 \w 或任何其他特定的字符样式,ptxt2pdf 基于属性的名称而不是属性所附加的标记来创建链接。
In case anyone reads such an old post, TeX has no idea where page breaks will be when it is arranging text into a paragraph, so unless you’re talking about lines into the paragraph, no, there’s no easy way to get line numbers.
If you know that your paragraph is crossing a page boundary, then the potential way to get line numbers would involve dropping the right sort of position-marking \write onto the page in the right place, which writes to the .parlocs file. At the end of the job, find the difference between that and the previous start of the page/column and dividing that number by the size of the baseline.
The maths, however, gets complicated by anything like a section-header, figure or change in line spacing, and of course it is based on the previous run, so the result might be wrong.
This is basically a more complicated version of how the offset cutouts for figures get calculated, (they only need to worry about the count into the paragraph) and the result there is … normally correct but not always.
Regarding the links, I don’t know if the above or the documentation is clear: the attributes don’t need to be attached to \w or any other particular character style, ptxt2pdf makes links based on the name of the attribute, not the marker the attribute is attached to.
机器翻译自 English