add tag
Anonymous 8173
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.
```
\documentclass[12pt]{article}
\begin{document}
Line 1

Line 2

Line 3 $\sum_f^f$

Line 4 $\sum_f^f$
\end{document}
```

__Question__
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?

Many thanks.
Top Answer
Anonymous 8173
I ended up with the following approach:

I set
```
\showoutput
\showboxdepth=100
```
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:
```python
import re

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
        continue
    if line.startswith(page_str):
        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:
        pages.add(current_page)

print('Pages')
print('\n'.join(map(str, sorted(pages))))
```

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.