# Numbers are reversed in \hbox with the bidi=basic-r babel option

I know that (in the words of the manual) bidi support in babel is taking its first steps, but there are already some things I'm liking better than the xelatex + bidi approach.

If you put numbers in an \hbox they come out reversed.

Consider this MWE (compile with lualatex):

\documentclass{article}
\usepackage[nil,bidi=basic-r]{babel}
\babelprovide[import=en-AU,main]{australian}
\babelprovide[import=he]{hebrew}
\babelfont{rm}{Linux Libertine O}
\begin{document}
10 \hbox{10}
\end{document}


This results in:

10 01

Can anyone suggest a work around for this?

(I realise I might be abusing the basic-r option because I probably really want basic-l [which doesn't exist]. But I thought I'd ask anyway.)

• What exactly are there in babel that you are liking better than bidi? as far as I can tell, babel is full of ugly bugs with both xetex and luatex engines. Sorry, but babel's bidi support is a mess and it is not suitable for any serious/production work.
– user118241
Jan 14 '18 at 1:09
• @user118241, bidi is definitely still the way to go since its much more mature. But because bidi patches so many packages, I occasionally bump up against load order problems. I also want to be able to use language variants with biblatex which is still an issue with polyglossia. And ultimately lualatex support would be nice. I happened across the issue in this post while experimenting with going from markdown to LaTeX. Having the possibility of being able not to mark up changes in languages looks interesting. Jan 14 '18 at 3:55
• @user118241, I know all this doesn't work properly yet, but given bidi support only appeared in babel last year it's a bit premature to call it's support 'full of ugly bugs and a mess'. I'm sure it will improve in time. Jan 14 '18 at 3:58
• No, it is premature to have a vain hope that babel will improve. The babel's bidi problems were reported on XeTeX mailing list when Javier became maintainer of babel and he himself asked for the problems. After more than several years (5 years?), babel is still no where in terms of bidi.
– user118241
Jan 14 '18 at 4:19
• The bidi package is used heavily at least in Iranian universities to the best of my knowledge for typesetting Persian using the xepersian package. It is under active rapid development unlike babel and has between 30,000 and 50,000 of users roughly only in Iran. The bidi package is used heavily for typesetting textbooks, theses and other academic work. It is used by the Iranian mathematical society and all Persian scientific conferences. So it is clear, that it is a safe tool for any serious/production work.
– user118241
Jan 14 '18 at 4:24

It seems a bit fragile, probably worth checking with Javier, however several things switch it back including an empty box

\documentclass{article}
\usepackage[nil,bidi=basic-r]{babel}
\babelprovide[import=en-AU,main]{australian}
\babelprovide[import=he]{hebrew}
\babelfont{rm}{Linux Libertine O}
\begin{document}
\showoutput
10 \hbox{20}

10 \hbox{20\hbox{}}
\end{document}

• Thanks! What's the right way to check with Javier on this? Open an issue on github? Jan 14 '18 at 3:59
• @DavidPurton that would work, yes Jan 14 '18 at 9:41

Your guess is correct -- basic-r only works with R text. Monolingual documents were the priority, and R scripts are intrinsecally bidi, unlike L scripts, which don't require bidi at all. Furthermore, a few words in Latin script inside an Arabic text don't require changing the font script (the Script key in fontspec), but the opposite is not true.

So basic-r was devised to deal with R text only. A basic model (for both R and multilingual L) is on the way, but I'd like to extend and improve (and fix) the new layout feature before. After all, I did not start the real work on bidi writing until a few months ago. I expect a basic complete support for LuaTeX will be complete before Summer, while XeTeX and pdftex must wait until Winter.

• No worries! Keep up the great work with babel! Jan 15 '18 at 23:12
• @Javier Bezos: Yes, if and only if you keep copying solutions from the bidi package without any sort of creativity on your own part and without honestly crediting the bidi package for the solutions that you have copied into babel from the bidi package. You have such excellent morals!
– user118241
Jan 18 '18 at 1:37
• Please, stop ranting and insulting. Jan 22 '18 at 14:38