2

I have a problem when I tried to compile this using XeLaTeX.

\documentclass{article}
\usepackage{ulem,amsmath,fontspec}

\begin{document}
\[1+1=2\]
\end{document}  

Is there any way to fix this?

  • Try loading fontspec before ulem. – Francis Jul 30 '13 at 1:20
  • 2
    @Francis you should write an answer. – Gonzalo Medina Jul 30 '13 at 1:28
  • @GonzaloMedina: I know there are conflicts, but I don't know what caused them exactly. – Francis Jul 30 '13 at 1:33
  • The conflict seems to be in the redefinition of \\ made by ulem. – egreg Jul 30 '13 at 9:22
  • @barbarabeeton: Maybe you shouldn't remove amsmath tag? This problem appears only if you load all three package together. – Francis Jul 30 '13 at 16:18
7

When ulem is loaded before amsmath and fontspec, the definition of \[ results being

> \[=macro:
->\protect \[  .

instead of the correct one

> \[=macro:
->\x@protect \[\protect \[  .

as defined by amsmath via `\DeclareRobustCommand.

The problem is due to the fact that ulem defines \MakeRobust; later fontspec loads fixltx2e that does \providecommand\MakeRobust[1]{...} and then \MakeRobust\[; so, instead of using the good definition of fixltx2e, the faulty version provided by ulem is used.

This should be considered as a bug in ulem: the package should load fixltx2e and use its version of \MakeRobust.

Loading ulem after fontspec somewhat cures the problem, but leaves in memory the bad definition of \MakeRobust, which could have effects if some later loaded package relies on fixltx2e version of \MakeRobust.

Perhaps, a better solution is to do

\usepackage{ulem}
\let\MakeRobust\relax
\usepackage{amsmath}
\usepackage{fontspec}

so that the faulty \MakeRobust is only used for ulem's purposes (which work) and then removed from memory, so that fixltx2e can give the good definition.

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.