3

I am trying to renew \overline into \bar in a Xelatex document but Xelatex does not compile and I do not understand why I get the error "\bar is already defined".

Here is my Xelatex code :

\documentclass{book}
\usepackage{polyglossia}
\setmainlanguage{french}

\renewcommand{\bar}{\overline}

\begin{document}
$\bar{ABCD}$\\
$\overline{ABCD}$
\end{document}

But when I am in normal Latex mode, this code compiles perfectly :

\documentclass{book}
\usepackage[francais]{babel}
\usepackage[T1]{fontenc}

\renewcommand{\bar}{\overline}

\begin{document}
$\bar{ABCD}$\\
$\overline{ABCD}$
\end{document}

I have been searching a related topic but so far, I have not found any solution.

( The answer here : Problem with renewcommand? did not work for bar )

Thank you for your help.

  • Try \let\bar\overline instead or \AtBeginDocument{\renewcommand{\bar}{\overline}} but I doubt the usefulness of the idea at all –  Apr 18 '17 at 20:33
  • 1
    The problem is that fontspec (loaded by polyglossia) tries to declare the \bar accent at \begin{document}. You must do your redefinition later, or use another name. – Ulrike Fischer Apr 18 '17 at 20:39
  • The first option does not work either, I have already tried it. But the second one is working, thank you very much ! :) – Adrien Meilac Apr 18 '17 at 20:41
  • @AdrienMeilac: Yes, forget the first option. It would work if used in \AtBeginDocument{...} however. –  Apr 18 '17 at 20:41
  • Ulrike Fische : Ok , Are there other commands like bar that I could not renew with polyglossia ?
  • – Adrien Meilac Apr 18 '17 at 20:42