HomeCopy a formula

Copy a formula out of a PDF

Select a formula in a PDF, copy it, paste it. What arrives depends on how the PDF was made. Both pastes below were taken from real PDFs by a text extractor when this page was built.

๐‘ฅ=โˆ’๐‘ยฑ๐‘2โˆ’4โข๐‘Žโข๐‘2โข๐‘Žx = \frac{-b \pm \sqrt{b^{2} - 4 a c}}{2 a}

Pasted from the PDF pdflatex makes

x=

โˆ’b ยฑ

โˆš

b2 โˆ’ 4ac
2a

Pieces, in the order they happen to sit on the page. The structure is gone.

Pasted from the PDF Intex makes

x = (โˆ’b ยฑ โˆš(bยฒ โˆ’ 4ac))/2a

One line, in reading order. Read back, it says the same words as the formula.

The same formula, typeset once by pdflatex and once by our software, each copied out of its PDF with pdftotext, the extractor of the poppler library.

Four more, the same way

Each formula was set alone in a one-page PDF by each program, and the PDF's text taken out with the same extractor.

Formulas, and the text a copy takes from each PDF
The formulaFrom the pdflatex PDFFrom the Intex PDF
โˆซโˆ’โˆžโˆž๐‘’โˆ’๐‘ฅ2d๐‘ฅ=๐œ‹\int_{-\infty}^{\infty} e^{-x^{2}} \, \mathrm{d} x = \sqrt{\pi}
Z โˆž
โˆ’โˆž

2

eโˆ’x dx =

โˆš

ฯ€
โˆซ_(โˆ’โˆž)^โˆž e^(โˆ’xยฒ) dx = โˆšฯ€
โˆ‘๐‘˜=1๐‘›๐‘˜=๐‘›โข(๐‘›+1)2\sum_{k = 1}^{n} k = \frac{n(n + 1)}{2}
n
X
k=1

k=

n(n + 1)
โˆ‘_(k=1)^n k = n(n + 1)/2
๐ด=(๐‘Ž๐‘๐‘๐‘‘)A = \left( \begin{array}{cc} a & b \\ c & d \end{array} \right)
๏ฟฝ
A=

a
c

๏ฟฝ
b
d
A = (a, b; c, d)
limโ„Žโ†’0๐‘“โก(๐‘ฅ+โ„Ž)โˆ’๐‘“โก(๐‘ฅ)โ„Ž\lim_{h \to 0} \frac{f(x + h) - f(x)}{h}
f (x + h) โˆ’ f (x)
hโ†’0
h
lim
lim_(hโ†’0) (f(x + h) โˆ’ f(x))/h

Viewers differ. This page used pdftotext; Acrobat, the PDF viewers in browsers and others extract text in their own ways, and a usual LaTeX PDF can come out differently scrambled in each.

It reads back as the same formula

A paste is only useful if it still means the formula. Paste the line from our PDF into the formula reader and it is read as mathematics again, with the same words a screen reader says for the original:

x = (โˆ’b ยฑ โˆš(bยฒ โˆ’ 4ac))/2a

x equals the fraction with numerator negative b plus or minus the square root of b squared minus 4 a c end root and denominator 2 a end fraction

That was checked for every formula on this page when it was built: the copied line, read back, gave the same words as the formula it came from.

What the line looks like

The copy text is written for a person first. Squares are superscript digits (bยฒ), a root keeps its contents in brackets (โˆš(bยฒ โˆ’ 4ac)), a fraction's numerator is bracketed when it is more than one term ((a + b)/c), and a sum carries its limits (โˆ‘_(k=1)^n).

It is plain Unicode text, so it survives an email, a chat message, a search box or a code comment. Read more in the note on what a copied formula should paste as.