thmtools icon indicating copy to clipboard operation
thmtools copied to clipboard

list of theorems in RTL context has LTR lines with hyperref

Open Udi-Fogiel opened this issue 9 months ago • 2 comments

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.

Udi-Fogiel avatar May 01 '24 16:05 Udi-Fogiel

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?

muzimuzhi avatar May 02 '24 11:05 muzimuzhi

That would probably be safer, indeed.

Udi-Fogiel avatar May 02 '24 13:05 Udi-Fogiel