Take the following table:
\documentclass{article}
\begin{document}
\begin{tabular}{|c|c|}
11 & 21 \\
12 & 22 \\
\end{tabular}
\end{document}
What are the techniques to make this table text-copyable (as much as possible)?
For example, Evince sees this as text (note that order and lines are lost):
11
12
21
22
(Acrobat does slightly better job in this case but still can get confused in larger tables).
One alternative I explored is to use accsup. However I don't know how to enforce tabs (between cell) and new lines; this doesn't work:
\documentclass{article}
\usepackage{accsupp}
\begin{document}
\BeginAccSupp{ActualText=11\t 21\n 12\t 22\n} %this line produces errors
\begin{tabular}{|c|c|}
11 & 21 \\
12 & 22 \\
\end{tabular}
\EndAccSupp{}
\end{document}
What code I have to put to get this as copyable text 11 \tab 21 \n 12 \tab 22 \n? Is there other technique to help the PDF viewer at lest follow (flow) the copyable text in a more sensible way?
EDIT: I made some mild progress using accsup by defining a line-by-line alternative text:
\documentclass{article}
\usepackage{accsupp}
\begin{document}
\begin{tabular}{|c|c|}
\BeginAccSupp{ActualText=11 21} 11 & 21 \EndAccSupp{} \\
\BeginAccSupp{ActualText=11 21} 12 & 22 \EndAccSupp{} \\
\end{tabular}
\end{document}
Still I don't know how to add the tab characters but the copying has improved
EDIT 2: I can produce a tab charactar with
\BeginAccSupp{method=hex,unicode,ActualText=0009} but then I can't combine it with normal text. (As in ActualText=a ?0009? b).
EDIT 3: A line-by-line variant from Heiko's answer:
\documentclass{article}
\usepackage{accsupp}
\begin{document}
\begin{tabular}{|c|c|}
\BeginAccSupp{method=plain, ActualText=11\string\t 21}
11 & 21
\EndAccSupp{}\\
\BeginAccSupp{method=plain, ActualText=12\string\t 22}
12 & 22
\EndAccSupp{}\\
\end{tabular}
\end{document}
expl3for this, I think, because table rows are horror to create through macro's.:-D– 1010011010 Aug 04 '14 at 18:17&by\BeginAccSupp{..., ActualText=0009} & \EndAccSupp{}but still the contents is scrambled. – alfC Aug 04 '14 at 19:31Okular? If you copy a selection as usual (text) it works the same way asEvince, butOkularhas also an interactive table selection tool, which helps to recognize table rows/cols and manually edit a grid. Just in case, your first table was copied nicely fromOkularVersion 0.14.3 intoExcelas well as intoGnumericspreadsheet. – g.kov Aug 05 '14 at 10:29