As far as I understood, LaTeX usually inserts a `\baselineskip` to separate two lines. However, if the lines overlap due to inline math (e.g. with exponents and indices), LaTeX inserts a `\lineskip` instead.
For example, in this MWE, the space between lines 3 and 4 is larger than that between lines 1 and 2.
Line 3 $\sum_f^f$
Line 4 $\sum_f^f$
Is there a way to detect and locate the lines with increased line spacing? Maybe in LuaLaTeX?
I heard about `\showoutput` and `\showboxdepth=3`, and indeed, I see many `\lineskip`s in the log file of my document. But I doubt that they are all originating from inline math. Also, how would I map them to the actual TeX source in a 100+ page document?
I ended up with the following approach:
in the document and compile (with LuaLaTeX). Then I go through the log file and find every `\lineskip` and the corresponding page. I ignore occurrences if the skip is
* of height 0
* between `\abovedisplay(short)skip` and `\belowdisplay(short)skip` (because then it is inside display math)
* one or two lines below `\belowdisplay(short)skip` (i.e., directly attached to the end of display math)
There are still some false positives, but I can live with that.
This is the Python script:
with open('document.log') as file:
lines = file.read().split('\n')
page_str = 'Completed box being shipped out '
ls_re = re.compile(r'\\glue\(\\lineskip\) [^0]')
pages = set()
current_page = 0
active = True
skip = 0
for line in lines:
if skip > 0: # skip a line in the log
skip -= 1
current_page = int(line.replace(page_str, '').strip(''))
elif r'\glue(\abovedisplayskip)' in line or r'\glue(\abovedisplayshortskip)' in line:
active = False
elif r'\glue(\belowdisplayskip)' in line or r'\glue(\belowdisplayshortskip)' in line:
active = True
skip = 2
elif active and ls_re.search(line) is not None: