muzimuzhi / thmtools

New home for LaTeX package bundle thmtools
LaTeX Project Public License v1.3c
16 stars 3 forks source link

list of theorems in RTL context has LTR lines with hyperref #65

Open Udi-Fogiel opened 2 months ago

Udi-Fogiel commented 2 months ago

consider the following example

\documentclass{article}
%\DeclareHookRule{begindocument}{thm-listof}{after}{bidi}
\usepackage{thmtools}
\declaretheorem{theorem}
\usepackage{hyperref}
\usepackage[RTLdocument]{bidi}
\ShowHook{begindocument}
\begin{document}

\begin{theorem}[name=Zorn's Lemma]
Test
\end{theorem}

\listoftheorems

\makeatletter
\ShowCommand\thmt@contentsline
\ShowCommand\contentsline
\end{document}

Notice how the words are written from left to right. This is because bidi patches \contentsline at the begindocument hook (because of hyperref), and since bidi must be loaded late, thmtools saves the wrong definition of \contentsline in \thmt@contentsline. It can be solved by declaring a hook rule.

muzimuzhi commented 2 months ago

Alternatively, the creation of \thmt@contentsline (line 229) can be deferred until \contentsline is locally redefined in \listoftheorems (line 86-88), thus patching order requirement is reduced as far as possible. https://github.com/muzimuzhi/thmtools/blob/ced87d57f0ce3e4cf37de9c1d87ecf7266b9fd19/source/thm-listof.dtx#L80-L88 https://github.com/muzimuzhi/thmtools/blob/ced87d57f0ce3e4cf37de9c1d87ecf7266b9fd19/source/thm-listof.dtx#L223-L230

What do you think?

Udi-Fogiel commented 2 months ago

That would probably be safer, indeed.