I would like to write a .pdf, where my readers could copy the rendered formulae and paste them directly in their TeX documents.

And the copied text would automatically be:

```
\int x\sin ax\;\mathrm{d}x = \frac{\sin ax}{a^2}-\frac{x\cos ax}{a}+C
```

Is this possible?

## Best Answer

The PDF format supports a feature "ActualText" that is used for copy-paste instead of the actual typeset text. However, it is not supported by all PDF viewers, but Acrobat Reader does support it.

Copy-paste result (

`\detokenize`

adds spaces after command names):A more verbatim-like copy is much more complicated:

Copy-paste result:

However, the argument of

`\copyable`

is read with verbatim catcodes. Therefore this trick will not work, if`\copyable`

is inside an argument of another macro (or in environments of package`amsmath`

). In this case the`\detokenize`

has a function to get the previous version with spaces after command names at least.## Discussion about areas

`\copyable`

inserts whatsits that does not influence the mathematical spacing. Thus the whole equation can be split:And where the mapping from formula to copy-paste text is correct,

`\copyable`

can be omitted:The area that is shown in the PDF viewer for selecting depends on the formula and especially the PDF viewer.

Acrobat Readerusually only shows the area above the first symbol of the formula. In case of the integral sign, a small rectangle above it. The latest example with AR9/Linux:Evince3.4.0 is a little better in the coverage of the rectangle. The first equation with the whole equation in`\copyable`

:But Evince has problems in the separation of the equations. Here I wanted to select the second equation only, but it gets mixed up with the third:

Okular0.14.3 has a nicer selecting tool, but if the`\copyable`

is split up into terms (second and third equations of the latest example), then the terms get mixed up. - Fatal for mathematicians.