# Strange effect of arabxetex/bidi on figure counter

I have a strange bug using XeLaTeX: I include caption.sty and use a command like \renewcommand\thefigure{\Alph{figure}} to make an adjustment to the figure counter. If then I include arabxetex.sty, the adjustment I made to the counter gets reverted.

See this MWE:

\documentclass{scrbook}
\usepackage{fontspec}
\usepackage{caption}
\renewcommand\thefigure{\Alph{figure}}

\usepackage[utf]{arabxetex}
\newfontfamily\arabicfont{Arial}

\begin{document}
\begin{figure}
\caption{Test figure}
\end{figure}
\end{document}


Result:

And compare:

\documentclass{scrbook}
\usepackage{fontspec}
\usepackage{caption}
\renewcommand\thefigure{\Alph{figure}}

%\usepackage[utf]{arabxetex}
\newfontfamily\arabicfont{Arial}

\begin{document}
\begin{figure}
\caption{Test figure}
\end{figure}
\end{document}


Result:

Does anyone now why this happens? I am aware that arabxetex.sty is loading bidi.sty and that there is the load order: first caption then bidi. But this order is respected in my case.

BTW: Loading arabxetex directly after caption would resolve the problem. But I am bound to this specific order of the commands as arabxetex is going to be loaded by a style package, while the first 4 lines are in the class. I'm also aware of the possibility to use \AtBeginDocument{\renewcommand\thefigure{\Alph{figure}}}, which would also work around the problem.

However, I'm really wondering: Is there a bug in arabxetex or bidi and what else is going to be affected by it? Maybe there's a lot more I need to put into \AtBeginDocument ;)

Thx.

• I can't see that it is a bug, you simply have two packages with commands that are redefining \thefigure so naturally which one wins depends on the order you execute the commands. – David Carlisle Nov 25 '16 at 0:36
• sometimes it's bad style but usually that's just the way it is, see all the packages redefining \cite you can't really stop them interacting in bad ways. I haven't looked what arabxetex is doing but probably switching between latin and arabic scripts for the numbers depending on context, hard to say it shouldn't be doing that. you get similar issues with babel languages eg \figurename is figure and you could redefine it to say table, but if you load babel and change language it'll get redefined again to a language variant, in the babel case it does provide hooks to add a definition – David Carlisle Nov 25 '16 at 12:18

\renewcommand\thefigure{\Alph{figure}}

after loading arabxetex package.