The following code demonstrates that \inputlineno
is broken. It does not give the correct line numbers for macros\groups, it treats a macro as a singular line. I see why this could be understood as the TeX file is treated as a token stream and macro's arguments may or may not be outputed.
So \inputlineno
is a sort of "expanded" line number.
\documentclass[12pt,oneside]{book}
\usepackage{xcolor}
\usepackage{everypage}
\AddEverypageHook{\typeout{Page = \thepage, Line = \the\inputlineno}}
\usepackage{lipsum}
\begin{document}
\textcolor{blue}{\lipsum}
\newpage
\textcolor{red}{This is a test cache1
\newpage
\lipsum
\newpage
\lipsum}
\newpage
\lipsum
\newpage
test
\newpage
xxxxxxxxxxxxxxxx
\end{document}
So, That may be the intended behavior but it is not what is generally said about inputlineno being the "source code line value".
Is there any way to fix this or get the actual source code line before expansion.
The above outputs
Page = 1, Line = 13
[1]
Page = 2, Line = 14
[2]
Page = 3, Line = 21 % note that texcolor ends here and spans 4 pages
[3]
Page = 4, Line = 21
[4]
Page = 5, Line = 21
[5]
Page = 6, Line = 21
[6]
Page = 7, Line = 24
[7]
Page = 8, Line = 26
[8]
Page = 9, Line = 26
[9]
Page = 10, Line = 28
[10]
Page = 11, Line = 30
while I want
Page = 1, Line = 13
[1]
Page = 2, Line = 13
[2]
Page = 3, Line = 17
[3]
Page = 4, Line = 19
[4]
Page = 5, Line = 19
[5]
Page = 6, Line = 21
[6]
Page = 7, Line = 21
[7]
Page = 8, Line = 25
[8]
Page = 9, Line = 25
[9]
Page = 10, Line = 27
[10]
Page = 11, Line = 29
(there may be a discrepancy because \inputlineno
and page seem to occur and the end of the page and source line below where it actually looks visually)
Basically all I need is to get the actual source code line that matches the page it is on before any expansions. So if some macro adds 100 pages of junk internally but only uses one short source code line then that is all I want.
It is similar to syntex but I would like to avoid and external processing.
I realize that macros can do anything they want, but I am not concerned with that. I am only concerned with mapping page numbers to actual source lines. If there is no page number that maps to some line then it doesn't effect what I'm trying to do. If there are lines that don't map to pages then it doesn't bother me. But for every source line that shows up on a page in some way, I want that page number.
Macros that generate stuff internally, that are not part of the actual source code, get whatever pages they span mapped to their line.
The \textcolor
macro usage above demonstrates this. It is not logical that we should ignore everything inside the macro and treat it as a singular line(which the first output demonstrates) when it is clear that it's arguments show up on different pages and there exists a mapping from the pages to the lines that is more informative than treating the macro as a atomic unit.