[Tex/LaTex] In which way have fake spaces made it to actual use

pdfpdftexspacing

I skimmed the abstracts of TUG 2014 and stumbled over "Fake spaces" with pdfTeX — the best of both worlds by Ross Moore. The abstract says:

With the 2014 version of TeX Live, new primitives are included within
pdfTeX that allow a pdffakespace to be inserted into the PDF
content stream, occurring between words and at the end of lines.

In particular, this is intriguing:

Also to be shown is how a fake space allows extra
material, such as the LaTeX source of inline or displayed mathematics,
to be included invisibly within the PDF. With a Select/Copy/Paste of
the mathematical expression, this included source coding comes along
with the pasted text.

Unfortunately, there are no slides available, and the proceedings do not seem to contain anything about this (not that I could access them, as a non-member).

What are current applications of these fake spaces? In particular, has copy-paste of mathematics been implemented so that it may be used without disadvantages?

Best Answer

In reference to your point, In particular, has copy-paste of mathematics been implemented so that it may be used without disadvantages

I don't know the particulars of what you cite, but the accsupp package allows different things to be displayed in a PDF versus what shows up in a copy paste.

REVISED SOLUTION (using Raphael's suggestion of \detokenize)

It would seem that \detokenize alleviates the need for separate arguments for the typeset and actual-pdf text, which will greatly streamline the use of this approach. I extend my thanks to him.

I also show how this even works for \displaystyle math.

\documentclass{article}
\usepackage{accsupp}
\newcommand\copypaste[1]{%
    \BeginAccSupp{method=escape,ActualText={\detokenize{#1}}}%
      #1%
    \EndAccSupp{}%
}
\begin{document}
What I have is \copypaste{$x^2 + y^2 = z^2$} and \copypaste{$\frac{1}{2}$}.  
Try to copy/paste me.
\copypaste{\[
y = \frac{\cos{x}}{1+\cos{x}}
\]}

Here it is with no copy/paste tuning: $x^2 + y^2 = z^2$ and $\frac{1}{2}$.
\[
y = \frac{\cos{x}}{1+\cos{x}}
\]\end{document}

Here is the PDF's appearance:

enter image description here

Now, when I go into Adobe Reader on the produced PDF file and hit ctl-A ctl-C to copy the whole document, the paste into a text file will appear as:

What I have is $x^2 + y^2 = z^2$ and $\frac {1}{2}$ . Try to copy/paste me.
\[ y = \frac {\cos {x}}{1+\cos {x}} \]
Here it is with no copy/paste tuning: x2 + y2 = z2 and 1
2 .
y =
cos x
1 + cos x
1

ORIGINAL EDITED SOLUTION to allow optional argument with different "ActualText" content, for example, to use \noexpand for certain math arguments.

\documentclass{article}
\usepackage{accsupp}
\newcommand\copypaste[2][\relax]{%
  \ifx\relax#1%
    \BeginAccSupp{method=escape,ActualText={#2}}%
      #2%
    \EndAccSupp{}%
  \else%
    \BeginAccSupp{method=escape,ActualText={#1}}%
      #2%
    \EndAccSupp{}%
  \fi%
}
\begin{document}
What I have is \copypaste{$x^2 + y^2 = z^2$} and 
  \copypaste[$\noexpand\frac{1}{2}$]{$\frac{1}{2}$}.  
Try to copy/paste me.

Here it is with no copy/paste tuning: $x^2 + y^2 = z^2$ and $\frac{1}{2}$.

\end{document}
Related Question