schlcht / microtype

The microtype package
https://ctan.org/pkg/microtype
LaTeX Project Public License v1.3c
81 stars 4 forks source link

support footnotes also if tagging is active #40

Open hpvd opened 2 days ago

hpvd commented 2 days ago

Description

support footnotes also if tagging is active currently there is a warning:

Package microtype Warning: Unable to apply patchfootnote' on input line 21.`

Minimal example demonstrating the issue

update code to current tagging best practice https://latex3.github.io/tagging-project/documentation/prototype-usage-instructions.html plus added title for passing pdf validation on https://dev.verapdf-rest.duallab.com/

original: https://github.com/latex3/tagging-project/issues/67

\DocumentMetadata{
  lang        = de,
  pdfversion  = 2.0,
  pdfstandard = ua-2,
  pdfstandard = a-4f, %or a-4
  testphase   = 
   {phase-III,
    title,
    table,
    math,
    firstaid}  
}

\documentclass{article}

\usepackage{microtype}

\title{test title}

\begin{document}

Simple text

\end{document}
schlcht commented 1 day ago

Thanks for the report. I was a bit hesitant as yet, thinking that tagging was still somewhat of a moving target. But let's see...

u-fischer commented 1 day ago

@schlcht regarding your comment in the commit

% \item The new footnote code (in \file{latex-lab-footnotes.ltx}), which is meant % to facilitate tagging, introduces many hooks, among them |fntext/begin|, which % would seem appropriate for us. Unfortunately, however, we cannot use it, as we'd % stumble over the hook management itself.

and your following patch: could you open an issue at https://github.com/latex3/tagging-project with an example why the hook doesn't work for you? I mean the main point of the new code and all the hooks is to avoid that people have to patch around and if that this doesn't work or is insufficient, we should correct the code.

schlcht commented 22 hours ago

@u-fischer The problem is that if I insert \leftprotrusion via the hook management, this command (which peeks ahead) would see the two hook commands \__hook_toplevel fntext/begin and \__hook_next fntext/begin instead of the actual contents of the footnote. To stick with the hook interface, I see two potential solutions: (1) either make microtype aware of these internal commands, so that it would peek ahead, or (2) add something like \@expandtwoargs\leftprotrusion to the hook. While neither of these solutions will actually patch internal code, both of them would still rely on the internal code structure (i.e. the fact that there are exactly two commands following, or their names). So I'm not quite sure whether either of these solutions would really be that much cleaner.

BTW: Is it within the specs of fntext/begin to contain actual text to be typeset?

u-fischer commented 12 hours ago

@schlcht Sorry I was a bit unclear. I quite understand (and expected) that it doesn't work in a hook. But imho using a hook for such peek ahead code isn't the right place anyway. A hook can be used by other packages and you do not have full control about when your chunk is executed. From your patch it looks as if \ignorespaces#1 should be something like \socket_use:n{fntext/peek}{#1} where the default plug simply adds the \ignorespaces. Then you could exchange the plug. So make a feature request about your use case!

schlcht commented 3 hours ago

@u-fischer ah, yes, that makes sense. I'll file a request later...