2

Is there any way to grep a pdf document (originally written in LaTeX) for the math "2^n" as in 2 to the power of n? I have pdfgrep but I don't know how you would use that to grep for math.

1 Answer 1

2

You can use e.g. mutool clean -d from the mupdf package to decompress the streams in a PDF file, then you can look at it (or grep it directly).

Unfortunately, text in PDF files is rendered by placing glyphs (or sequences of glyphs) at pre-calculated coordinates. So both $2^n$ and $$2^n$$ will consist of two glyphs for 2 and n in different positions, and this is really difficult to match with a regular expression.

I suggest you decompress your pdf document and have a look at how the text rendering actually looks like.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.