# tufte-book & Tectonic (XeTeX) & bidi / polyglossia don't get along

I'm trying to write a document with tufte-book. Most of the document is supposed to be in English but I wish to write some text in Hebrew. I am able successfully compile documents with more common document classes with polyglossia and Tectonic which internally uses XeTeX. But with tufte-book and this MWE:

%! TEX program = xelatex
\documentclass[nols,nobib,bidi]{tufte-book}
% Language
\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguage{hebrew}
\begin{document}

Hello World.

\end{document}


I get this weird error:

****************************************************
(biditools.sty) (zref-abspage.sty (zref-base.sty)) (latex-xetex-bidi.def

! LaTeX Error: Command \XeTeX already defined.
Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
...

l.138 ...di@reflect@box{E}}\kern-.1667em \TeX}}\$}}


I'm using tufte-book from it's Git repository. Is this a polyglossia bug or a tufte bug? I'd also like to know what use can I find for the bidi option in tufte-book \documentclass.

Lastly, this question suggests to use biditufte-book class provided by the bidi package but I can't use it since I'd like to use biblatex and biditufte-book doesn't support the nobib option which I need.

• The tufte suite should be updated not to load xltxtra. This package loads metalogo and this is the problem, because bidi doesn't check whether \XeTeX and \XeLaTeX are already defined (which is also wrong). Just add \let\XeTeX\relax and \let\XeLaTeX\relax before \usepackage{polyglossia}. Mar 16, 2021 at 18:38

It's a combined problem.

The tufte-book.cls loads tufte-common.def that, when XeLaTeX as processing engine is detected, does \RequirePackage{xltxtra}, which used to be recommended several years ago, but now it's definitely recommended not to load it.

What happens? That xltxtra loads metalogo, which defines the commands \XeTeX and \XeLaTeX.

Later, bidi does an unconditional definition of both commands, without any check on whether they're already defined, which is obviously wrong. It should first remove possible definitions of the commands, and then add its own adaptation for bidirectional typesetting.

Fix:

%! TEX program = xelatex
\documentclass[nols,nobib,bidi]{tufte-book}

\let\XeTeX\undefined
\let\XeLaTeX\undefined

% Language
\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguage{hebrew}

\begin{document}

Hello World.

\end{document}
`