以防有人閱讀這麼舊的帖子,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