3

I get an error and I don't know the reason:

(d:/texlive/2012/texmf-dist/tex/latex/enumitem/enumitem.sty)                      
(d:/texlive/2012/texmf-dist/tex/latex/tools/xspace.sty)                           
(d:/texlive/2012/texmf-dist/tex/latex/amsfonts/amsfonts.sty)                      
(d:/texlive/2012/texmf-dist/tex/latex/mh/breqn.sty                                
(d:/texlive/2012/texmf-dist/tex/latex/mh/flexisym.sty                             
(d:/texlive/2012/texmf-dist/tex/latex/mh/cmbase.sym)                              
(d:/texlive/2012/texmf-dist/tex/latex/mh/mathstyle.sty)))                         
(d:/texlive/2012/texmf-dist/tex/xelatex/polyglossia/gloss-english.ldf          

! LaTeX Error: \do undefined.                                                     

See the LaTeX manual or LaTeX Companion for explanation.                          
Type  H <return>  for immediate help.                                             
 ...                                                                              

l.6 }                                                                             

?

I think this is the following line which generate it:

  \usepackage{polyglossia}
  \setotherlanguage{english}    

But why?

UPDATE Small example: File1.tex:

\documentclass[a4paper, 10pt, twocolumn]{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{algpseudocode}
\usepackage{fancyhdr}
\usepackage{enumitem}
\usepackage{xspace}
\usepackage{amsfonts}
\usepackage{breqn}
\setotherlanguage{english}

\setmainfont{Consolas}

File2.tex

\input File1.tex
\begin{document}

\section{Section}
\end{document}

UPDATE2

Here is the log

user14416
  • 838

2 Answers2

4

Why the weird file structure?

Anyway, there seems to be some strange interaction between the packages, in particular I had to move amsthm this loads without error with xelatex File2

File1.tex:

\documentclass[a4paper, 10pt, twocolumn]{article}
\usepackage{amsthm}
\usepackage{fontspec}

\usepackage{polyglossia}
\usepackage{algpseudocode}
\usepackage{fancyhdr}
\usepackage{enumitem}
\usepackage{xspace}
\usepackage{amsfonts}
\usepackage{breqn}
\def\do{}
\setotherlanguage{english}

\setmainfont{Consolas}
\def\do{}
David Carlisle
  • 757,742
  • Hi David. There is an incompatibility between Polyglossia and amsthm, in the sense that Polyglossia, via fontspec, includes fixltx2e, that makes \[ protected (amongst others). However amsthm tries to redefine it (around line 400), and fails. I have contacted the AMS in order to try and resolve this; however for the moment the easiest workaround, as you’ve found out yourself, is to load amsthm before Polyglossia, fontspec, or any other package that loads fixltx2e, for that matter. – Arthur Reutenauer May 23 '13 at 12:48
  • Oh, and you don’t need to include fontspec at all in your document, Polyglossia does it for you. – Arthur Reutenauer May 23 '13 at 12:50
2

For mysterious reasons, flexysym.sty, which is loaded by breqn.sty, does

\edef\do{%
  \noexpand\AtEndOfPackage{%
    \catcode\number`\"=\number\catcode`\"
    \relax
  }%
}
\do \let\do\relax

In the LaTeX kernel, \do is used in many places as a scratch control sequence, but never it is said \let\do\relax. Unfortunately, polyglossia relies on this fact and gloss-english.ldf uses \renewcommand*\do[1]{...}.

This should be regarded as a bug both in breqn and in polyglossia.

Saying \def\do{} after \usepackage{breqn} cures the problem.


A better way to do what flexysym.sty does is

\begingroup\edef\x{\endgroup
  \noexpand\AtEndOfPackage{%
    \catcode\number`\"=\number\catcode`\"
    \relax
  }%
}\x

without using \do which is usually defined (with various meanings) as a macro with an argument.

egreg
  • 1,121,712
  • Hi Enrico. To address the Polyglossia end, I’m going to use \def instead of \newcommand; can you see any side effect to that change? – Arthur Reutenauer May 23 '13 at 12:49
  • @ArthurReutenauer There should never be a problem in doing \def\do{...} instead of \renewcommand*{\do}{...}. I'd even say it's the best approach. – egreg May 23 '13 at 12:51
  • Thanks, that’s what I wanted to hear ;-) I have to say it seemed odd to me that François chose \renewcommand instead of \def, and I always meant to look into it. – Arthur Reutenauer May 23 '13 at 13:26