# Is there a way to make a “non-selectable” space in LaTeX?

Is there a way to create a horizontal space in LaTeX that is visible to the reader but invisible to the computer when selecting and copying text (using PDFLaTeX)?

An example of the problem: When I read a PDF that has a bank account number in it and I want to manually type/write it into a banking form, it helps a lot to have regular spacing in the number, e.g. "Bank Account no. 123 456 789". However, when I use online banking, the form field does not expect spaces in the number and additionally has a limited length. So when I copy&paste the number from the PDF, all I get in the form field is "123 456 7", because it's limited to 9 characters and it copied the spaces.

So the question is: Can I get LaTeX to show spaces that help readability but that are not selected/copied when copying the text? I still want to read "123 456 789", but when I select and copy that text, I want "123456789" in my clipboard.

I searched for spacing-related topics and tutorials, but only found the usual commands (such as \hspace or \hskip). Using tables or arrays does not help either, there's always a selectable space or even a newline.

Thanks a lot in advance for any help!

-
You can use the accsupp package to provide alternative text: tex.stackexchange.com/a/18509/2388 –  Ulrike Fischer Feb 6 at 10:18
Thank You very much! –  Fred Feb 6 at 17:57

You can use the accsupp package to specify which text should be copied:

\documentclass{article}
\usepackage{accsupp}

\begin{document}
Account number: \BeginAccSupp{ActualText=123456789}%
123 456 789%
\EndAccSupp{}%
\end{document}


A quick test suggests that this works with pdflatex and lualatex, but not with xelatex.

-
Does it work with PdfLaTeX, XeLaTeX, LuaLaTeX or all of them? I'm just asking since this information might turn out helpful. –  tohecz Feb 6 at 10:21
@tohecz: Good point. I've edited my answer. –  Jake Feb 6 at 10:28
Also, does this work with all PDF viewers or only some? I guess you can't know that, but which did you test? I know they often behave different with respect to what is copied. –  cfr Feb 6 at 17:15
Thanks a lot! This solution is perfect! I tested it with evince, okular and Adobe Reader on Linux and it works with all of them (though okular swallows a space sometimes, apparently). –  Fred Feb 6 at 17:57