thmtools
thmtools copied to clipboard
list of theorems in RTL context has LTR lines with hyperref
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.
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?
That would probably be safer, indeed.