persiantex / bidi

Bidirectional typesetting in plain TeX and LaTeX, using XeTeX
https://ctan.org/pkg/bidi
8 stars 0 forks source link

Prevent “helpful” redefinitions #21

Open dahosek opened 3 years ago

dahosek commented 3 years ago

Provide check to allow document classes to declare themselves bidi-aware

There should be a way for a document class to indicate to bidi that they do not need bidi to redefine things for R-L support. This often results in unexpected behavior, as indicated in the tex.se links below. Perhaps the most egregious is that a document class that builds on any of the common document classes might see its formatting overwritten because of, e.g., a few passages of Hebrew, Arabic or Persian that appear in the document.

Check/indicate

https://tex.stackexchange.com/questions/596977/best-practice-for-dealing-with-bidis-redefinitions-for-class-authors https://tex.stackexchange.com/questions/602037/titlesec-package-not-suppressing-chapter-number-from-section-in-xelatex

Minimal example

does not apply, exactly, but here's an minimal version of a document class that might find itself affected:

\LoadClass{book}
\renewcommand{\thesection}{\arabic{section}}

Expected behavior

\thesection should not be modified by bidi. Perhaps by doing something like

\providecommand{\@bidiawareclass}{}

and then having bidi do a check with

\ifdef\@bidiawareclass
\else
  all the redefinitions for assorted classes go here
\fi

or alternatively, using some mechanism like etoolbox's \patchcmd and/or the newer LaTeX hooks would be a more robust way of effecting changes without necessarily damaging existing document classes. If you're open to it, I'd be willing to do a proper PR for some of that code.