# Cannot find LaTeX Error

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

-
Welcome to TeX.sx! The code you provided runs fine. Please add a minimal working example (MWE) that illustrates your problem. –  Silke Oct 27 '12 at 20:42
Note that you need to use \input{File1.tex}. –  Werner Oct 27 '12 at 20:47
@Qrrbrbirlbel Undefined control sequence. –  user14416 Oct 27 '12 at 20:51
@Werner Does not matter\ –  user14416 Oct 27 '12 at 20:51
Are you using XeLaTeX? fontspec will only work with XeLaTeX or LuaLaTeX. –  matth Oct 27 '12 at 20:54

## 2 Answers

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{}

-
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

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.

-
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