I don't know how to properly ask this question nor if the term encoding is appropriate for this issue, so I'll start with an example. Say I define a new command \R for the set of real numbers as follows
\newcommand\R{{\rm I\!R}}
so that the output will be something like
.
Basically I merge capital letters "I" and "R" to produce something in between a plain-text and a blackboard-bold R. When I select and copy the symbol on the pdf output, the copied text is reasonably the string "IR" rather than just "R".
My question is, is there any way to define what plain text should be copied (and matched using pdf reader find tool) in the pdf text selection? In the example above I would like the output of \R to be copied as "R" only, for instance.
More generally, is it possible to define the wanted behavior on arbitrary (more complex) commands? For instance, something like
\EncodeAs{plain-text-string}{TeX-command}
so that in the example above I could define
\newcommand\R{\EncodeAs{R}{{\rm I\!R}}}

accsupppackage is what you want. Here is one of my answers using it to produce different output in PDF visual versus PDF copy/paste: http://tex.stackexchange.com/questions/198516/is-there-such-thing-as-visual-only-whitespace/198519#198519. – Steven B. Segletes Nov 11 '16 at 15:22\documentclass{article} \usepackage{accsupp} \newcommand\R{{\rm I\!R}} \begin{document} \BeginAccSupp{method=escape,ActualText=R}% $\R$% \EndAccSupp{}% \end{document}– Steven B. Segletes Nov 11 '16 at 15:26