I looked up for different solutions about how to include alternative text for images in LuLaTeX (1.17.0). I found the following solution

\BeginAccSupp{method=escape, ActualText=2. Tag \%4,space}
    \BeginAccSupp{method=plain, ActualText=abc\%4,space}

Some questions with the above code:

  1. I am not clear if the \BeginAccSupp and \EndAccSupp should include the graphic or not. I didn't find a comment in the documentation. I'm thinking it might get tricky with the placement of image across pages.

  2. When I read the documentation of accsupp I read that the method plain might result in invalid PDF files since special chars are not protected. Does anybody know what special chars are referred to? I was thinking about the % but obviously this is double escaped in the PDF file:


Is there a way to correct it?

  1. Reading the documentation I can use as well pdfliterals. But somehow I didn't succeed with - is there a way to correct it?

    \pdfextension literal direct{/ActualText(2. Tag \%4)}

end in

/ActualText(2. Tag \%4)
  1. Is it better use the package options or encode by oneself the pdfstring and use pdfliteral? (once I have a working sample)
  • well you can use pdfliteral but your syntax is simply plain wrong. accsupp knows the correct syntax, so why do you want to avoid it? Jun 14 at 16:09
  • No specific reasons - just as its mentioned there and there is no sample code there I tried it. Since there is also no "recommendation" to it in the docu I asked here (see q4)
    – LeO
    Jun 14 at 16:24
  • as a side remark: the actualtext is not the same as an alternative text. If you want to add a description you should use /Alt. Jun 14 at 16:40
  • Thx for the hint - I wouldn't have recognized the difference without your pin pointing! You have an answer as well for the first two questions?
    – LeO
    Jun 15 at 7:24

1 Answer 1

  1. The ActualText is a replacement text for the content and should surround it. For an image that is no problem as that is a box and so won't break over pages.

  2. The syntax of a literal string is described in the PDF reference. Beside other you have to escapes parentheses (as they are used around the whole string), backslash, and you have to map non-ascii chars to some octal or similar representation. This is what the escape method do. As soon as you have TeX macros in it (and this includes macros like \%) it is safer to use the pdfstringdef method.

  3. If you want to use \pdfliteral directly (but be aware that this is pdftex specific, luatex and xetex need other commands) you must use them before and after your content. You can use \showoutput to see what exactly accsupp is inserting:

.\pdfliteral page{/Span<</ActualText(\(test\))>>BDC}
...\glue(\topskip) 6.28543
...\hbox(4.71457+0.0)x360.0, glue set 327.79163fil
....\OT1/cmr/m/n/10.95 x
....\OT1/cmr/m/n/10.95 x
....\glue 3.65 plus 1.825 minus 1.21666
....\pdfliteral page{EMC}

Side remark: do not put too much trust into this space option. ActualText normal works fine if you use a screen reader, but when copy&paste you are at the mercy of the heuristics of the PDF reader, and half of the time they ignore the setting.

  • Thx for the details response. I have now a better idea about 1) and 2) - and the PDF viewer are dealing the same situation quite differently - I know :-/ l need to live with that fact
    – LeO
    Jun 15 at 11:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .