Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with microtype #4

Open
callegar opened this issue Feb 24, 2022 · 7 comments
Open

Issues with microtype #4

callegar opened this issue Feb 24, 2022 · 7 comments

Comments

@callegar
Copy link

callegar commented Feb 24, 2022

Looks like using setspace together with microtype makes it impossible for the latter to patch the footnote command as it would like.
Issue has also been opened for the microtype package. schlcht/microtype#11

@davidcarlisle
Copy link
Member

20+ years ago the comment

% GT: Next line added. Hook desired here!

was added to this package....

It is possible that now we could use the general LaTeX command hook mechanism to add code here rather than re-writing \@footnotetext completly, that should allow pacakges to add features without tripping over each other. However would take a bit of investigation.

Notably here footmisc as well as microtype wants to adjust this command. @FrankMittelbach may have a view here as he's been looking at footnotes recently.

@FrankMittelbach
Copy link

Notably here footmisc as well as microtype wants to adjust this command. @FrankMittelbach may have a view here as he's been looking at footnotes recently.

This is only solvable well through a joint effort. Plan of attack:

  • OR code for footnote handling is currently under review
  • The rewrite inside footmisc is "roughly" in the direction it will finally go
  • But so far that is lacking a number of additional hooks (and is lacking a proper concept for the configuration points, where only one class or package can make updates)

The setspace overwrites are of the type "hook", ie there it just needs a suitable hook in the new code to allow such additions. My guess (but I have not checked) is that microtype has a similar need to configure what happens inside \footins and perhaps other parts --- this would need input from @schlcht to ensure that the right kind of hooks are enabled/offered.

All that will show up first only in the -dev release and probably and from my timeline initially not in 2022-06 but only in latex-lab code there (ie only activated if \DocumentMetadata is used). Once properly tested it could then move into main in Fall and footmisc, setspace, microtype, ... could start using hooks rather than overwriting each other.

@schlcht
Copy link

schlcht commented Feb 25, 2022

The reason why microtype fails to apply its footnote patch is only because in the example document setspace is loaded after hyperref: microtype includes a dedicated footnote patch for hyperref, but the hyperref definition is overwritten by setspace (which microtype isn't aware of). There would be no problem if hyperref were loaded after setspace (which is also common advice) or not at all.

So I would say the problem lies with setspace for blindly overwriting \@footnotetext. This also breaks any other classes or packages that have their own footnote definition. Instead, it could take a more cautious approach and patch the command (eg., by means of etoolbox), similar to what microtype does (which BTW does not overwrite any existing definition).

Regarding hooks in @footnotetext, I suspect the ship has sailed long ago. Grepping for \def@footnotetext in my (quite incomplete) texlive already yields two dozen redefinitions, all of which would have to be amended for the hook to be really usable. But just for the record, what microtype would need would be a hook just before the actual footnote text, so between \ignorespaces and #1.

@callegar
Copy link
Author

I understand that until the situation is completely fixed through the joint effort illustrated above, users should be careful in loading setspace before hyperref.

I assume that in this way one shall get the hyperref patch to footnote and not the one in setspace. Is this actually the case or is hyperref careful enough to patch @footnotetext keeping in place what setspace was trying to accomplish?

@davidcarlisle
Copy link
Member

hyperref saves (and calls) the version current at the point of its patch as \H@@footnotetext so in

> \H@@footnotetext=\long macro:
#1->\insert \footins {\def \baselinestretch {\setspace@singlespace }

you see it calls the setspace addition to set the linespacing.

\documentclass{article}

\usepackage{setspace}
\makeatletter
\show\@footnotetext
\usepackage{hyperref}
\show\@footnotetext
\show\H@@footnotetext

\begin{document}


\end{document}

@FrankMittelbach
Copy link

Regarding hooks in @footnotetext, I suspect the ship has sailed long ago. Grepping for \def@footnotetext in my (quite incomplete) texlive already yields two dozen redefinitions, all of which would have to be amended for the hook to be really usable. But just for the record, what microtype would need would be a hook just before the actual footnote text, so between \ignorespaces and #1.

we have to clean up these kind of things if we want to keep LaTeX useful. Tagging will never work otherwise and anyway this constant overwriting becomes more and more a nightmare. In that particular case it isn't too bad (I just went through the whole of TL and checked) and in any case unconditional overwrites always break stuff, you can't make all packages the last one, so mid term hooks instead of overwrites are the only sensible way in my opinion and such packages then need to follow or tough ... some newer features aren't available (or vanish). With a bit of goodwill that should work and it would be transparent to users.

@FrankMittelbach
Copy link

The new footnote support contains hooks that can deal with this issue but it will take probably one or two LaTeX releases before this will be generally available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants