AndyClifton / accessibility

A CTAN-compliant version of the LaTeX `accessibility` package
37 stars 6 forks source link

Xe(La)TeX and \pdfobj #53

Open ByronAhn opened 10 months ago

ByronAhn commented 10 months ago

Describe the bug Compiling any document with Xe(La)TeX and accessibility.sty leads to an error in compiling; something like:

./accessibility.sty:81: Undefined control sequence.
<recently read> \pdfobj 

l.81 \pdfobj
             reserveobjnum%

./accessibility.sty:81: LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.81 \pdfobj r
              eserveobjnum%
./accessibility.sty:82: Undefined control sequence.
<argument> ... c@StructTree\endcsname \pdflastobj 
                                                  \relax 
l.82 \setcounter{StructTree}{\pdflastobj}

It seems to me this is because \pdfobj is not a defined under the XeTeX engine (see this thread on tug.org).

To Reproduce Steps to reproduce the behavior:

  1. Write a MWE that works under pdfTeX, e.g.:
    \documentclass{article}
    \usepackage{accessibility}
    \begin{document}
    This is a test.
    \end{document}
  2. Try compiling that same .tex document using XeLaTeX, get errors.
  3. The compiled PDF looks like this:

    reserveobjnum =0=6 reserveobjnumThis is a test.

Expected behavior It should compile, but it does not.

Version

AndyClifton commented 9 months ago

Thanks @ByronAhn for reporting this.

As you noted, the accessibility package was not designed to work with Xe(La)Tex, so I think it's unlikely this will be fixed by a simple tweak to the accessibility package.

The use of the \pdfobj is fairly central to the package, but the link you provided to TUG does imply that it might be possible to detect the compiler and choose the right construct. For various reasons though (chiefly, not enough hours in the day) I will not be pushing this. You are welcome to try!

You may be aware that the LaTeX team has a project ongoing to bake accessibility in to the PDF generation process as a core function of LaTeX, i.e. in the kernel. This is described e.g. here and you can see a more complete list of related publications here.

@FrankMittelbach is there anything you would like to add about how the ongoing project and potential kernel changes will impact Xe(La)TeX? This may be obvious for some, but not for all.