AndyClifton / accessibility

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

Incompatible with separate TOC names for chapters/sections etc. #51

Closed lempelto closed 9 months ago

lempelto commented 1 year ago

Hello

It seems that trying to use the optional argument to give a chapter/section/subsection a shorter name in the table of contents, eg. \section[toc-name]{actual name} is not working with the accessibility package enabled. It took me a while to figure out but I'm now relatively certain that it is this package that is causing the issue. What would happen is basically that the section would be named "[" in the TOC, and "t" where the section starts and the first paragraph in the section would read "oc-name]actual name" This is what happened when I tried to add alt titles to a document that was already using the package.

I also did a test adding the accessibility package to another document that already had TOC titles that I knew worked. Compiling that with pdflatex seemed to spin into an infinite loop but gave the following warning Package accessibility Warning: empty \PopStack? on input line 294.

This short little example is enough to reproduce the error:

\documentclass{article} \usepackage[tagged,highstructure]{accessibility} \begin{document} \section[Sect.]{Section} Let's add some text \end{document}

The code will produce something that looks like this: Screenshot from 2022-11-09 02-30-04

car222222 commented 1 year ago

This package is (for some time now) described (in News) as follows:

it should be considered "not maintained".

AndyClifton commented 1 year ago

Thanks @lempelto for reporting that issue. It's an interesting one!

As @car222222 pointed out I am no longer maintaining the code and am just collecting issues.

I've stopped working on the package as it's basically not possible to implement something effective this way. Any change to the LaTeX kernel or any other package can be a breaking change for this package, and so it's a constant game of catch-up.

Fortunately there's an initiative by the core LaTeX team to introduce native tagging and structure as part of the LaTeX kernel. You can find out more here about the project, and current status is reported here. TL; DR: wait 1-2 years and you'll see PDF tagging automatically.

lempelto commented 1 year ago

Hi @AndyClifton and thanks for the response!

To be honest, I did read and know that the code wasn't maintained just before opening the issue but I figured I'd post it anyway since I already put it together. I totally sympathize with the reasoning. It does seem like a losing battle and it's good that it will be taken care of by the LaTeX team in the future.

Now, to someone who may or may not be writing a thesis, waiting 1-2 years might not be a great option, so I did end up fixing the issue or at least duct-taping the thing together for my own purposes. I also adjusted how the code handles tabular environments.

I thought I could attach my own modified accessibility.sty file (extension changed to .txt) here just in case there's that one person who happens to be in my exact situation. accessibility.txt

AndyClifton commented 1 year ago

@lempelto - awesome! I'll check that out and see what can be borrowed.

The fun thing about LaTeX is that I need to make those changes in the .dtx file, which is then compiled to produce the documentation and .sty file...

AndyClifton commented 1 year ago

@lempelto: Thanks for the new .sty file. I've implemented the changes in your .sty file and the short names for sections work. I've set up a test document for this in tests/article/TOC-names.

But: the changes you suggest to the list environment seem to break simple itemized lists. Check out tests/article/itemize for an example. The error message is simple: LaTeX Error: \begin{PDFList} on input line 13 ended by \end{itemize}. Specifically, it seems related to the following code that you suggest:

\let\originallist\list%
  \let\originalendlist\endlist
  \renewenvironment{list}%
    {\begin{PDFList}\originallist}%
    {\originalendlist\end{PDFList}}%
  %

If I remove this, the unit tests work fine.

Could you try some of the unit tests e.g. itemize, please, with your .sty file?

My version of the code is on the "issue51" branch.

lempelto commented 1 year ago

Alright, very interesting.

This could be a remnant that I've forgotten in the code. TLDR: I tested some stuff and made a few changes to lists. It could be completely fine to remove that part but I'll test if it breaks something else in my own works if/when I find the time. It is a bit weird that I don't remember getting the error you get.

The backstory, if you're interested: The \item command allows an optional custom label for each item. The thesis template I'm working with uses this to create a list of people (author, reviewer, opponent, etc.). There is this small bug that was annoying me where the screen reader I have available for me to test accessibility features with finishes each item by reading the label of the next one. I've been trying to work out why it's doing it and if I could fix it. Not a critical error, but a bit annoying and potentially confusing.

lempelto commented 1 year ago

Hi

I ran the unit tests using my original .sty file and I do now get the same error message LaTeX Error: \begin{PDFList} on input line 13 ended by \end{itemize}. I still don't get this error when compiling my other project and I have no idea why. I guess it doesn't matter for now. The new code without the renewed list environment works fine for everything. I think I was right that it was just something I forgot to delete, sorry about that.

AndyClifton commented 9 months ago

Forgot to close this when I did the PR #52 .