12

In the following example, I can't manage to make accsupp store the unicode alternative text. The resulting PDF looks as expected but the copyable text is not the correct one. I tried this with different accsupp options: method=plain,...=escape, ...=pdfstringdef, and unicode. (accsupp manual is here). I tried with Acrobat 9.4.1 (Linux) and Evince. I am using LuaLaTeX to compile.

The idea is that when I select the equation in the next document the text ⅆa is copied. (In most cases only a gets copied.)

\documentclass{article}
\usepackage{fontspec}
\usepackage{accsupp}

\begin{document}

\BeginAccSupp{unicode,ActualText=ⅆa} %method=plain, ...=escape, ...=pdfstringdef
$da$
\EndAccSupp{}

\end{document}
12

Big chars (characters with more than 8 bits) of LuaTeX/XeTeX are not yet fully supported. Workaround:

\documentclass{article}
\usepackage{fontspec}
\usepackage{accsupp}
% \usepackage{luatex85} % might be needed as a workaround https://github.com/ho-tex/oberdiek/issues/36

\usepackage{tikz}%\usepackage{pgfmath}
\usepackage{stringenc}
\usepackage{pdfescape}

\makeatletter
\newcommand*{\BeginAccSuppUnicode}[1]{%
  \EdefSanitize\asu@str{#1}%
  \edef\asu@str{%
    \expandafter\expandafter\expandafter\asu@ToSpaceOther
    \expandafter\asu@str\space\@nil
  }%
  \expandafter\let\expandafter\asu@str\expandafter\@empty
  \expandafter\asu@ToHexUC\asu@str\relax
  \EdefUnescapeHex{\asu@str}{\asu@str}%
  \StringEncodingConvert{\asu@str}{\asu@str}{utf32be}{utf16be}%
  \EdefEscapeHex{\asu@str}{\asu@str}%
  \BeginAccSupp{%
    unicode,%
    method=hex,%
    ActualText=\asu@str
  }%
}
\begingroup
  \lccode`\9=`\ %
\lowercase{\endgroup
  \def\asu@SpaceOther{9}%
}
\def\asu@ToSpaceOther#1 #2\@nil{%
  #1%
  \ifx\\#2\\%
    \expandafter\@gobble
  \else
    \asu@SpaceOther
    \expandafter\@firstofone
  \fi
  {\asu@ToSpaceOther#2\@nil}%
}
\def\asu@ToHexUC#1{%
  \ifx#1\relax
  \else
    \pgfmathHex{\the\numexpr`#1+"10000000\relax}%
    \edef\asu@str{%
      \asu@str
      0\expandafter\@gobble\pgfmathresult
    }%
    \expandafter\asu@ToHexUC
  \fi
}
\makeatother

\begin{document}

\BeginAccSuppUnicode{ⅆa}
$da$
\EndAccSupp{}

\end{document}
  • mmm, I get this ! Undefined control sequence. // l.108 \pgfkeys with LuaLatex Version beta-0.76.0-2013122811 (TeX Live 2014/dev) (rev 4627). – alfC Apr 14 '14 at 5:38
  • ".. are not fully supported yet" by who? by accsupp or by xe/lualatex? – alfC Apr 14 '14 at 5:40
  • 1
    @alfC: Try with \usepackge{tikz}. There might be an issue with missing module dependencies of pgf/TIkZ, because the code only uses \pgfmathHex. – Heiko Oberdiek Apr 14 '14 at 5:46
  • 1
    @alfC: For example, packages stringenc and pdfescape, accsupp could be updated to support "big chars". A clear and unambiguous specification for the support of "big chars" is probably the most difficult part. – Heiko Oberdiek Apr 14 '14 at 5:50
  • 2
    @alfC: For example, you can't use \verb inside an argument. The package just provides the basics, but onthe other hand, it supports different formats including plain TeX. Thus, just make a nice cozy command. e.g. something like \newcommmand{\accsupp}[2]{\BeginAccSupp{<options>,ActualText={#1}}#2\EndAccSupp{}} which hides the option settings from the user interface. – Heiko Oberdiek Apr 14 '14 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.