0

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:

enter image description here

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:

enter image description here

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
  • Ah, I see. But isn't it a bad style at least to use \renewcommand on an external command in a package? What if you have two packages doing this, which one would you include first? (I know the same goes to my address as I was just writing a package using \renewcommand on \thefigure.) – LaTechneuse Nov 25 '16 at 10:41
  • 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
1

There is no strange thing; just put

\renewcommand\thefigure{\Alph{figure}}

after loading arabxetex package.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.