# Is the limits command “\lim” incompatible with XeLaTeX?

everybody.

I have problems with the limits command "\lim" when I compile with XeLaTeX and I use the fontspec package. Let me explain it with one example:

If don't use the fontspec package (because I need to use several True Type Fonts), this code produces no errors:

\documentclass[letterpaper,reqno]{book}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
%\usepackage{fontspec}
\usepackage{amssymb,amsmath,amsthm}

\begin{document}
$\lim f(x)$
\end{document}


And the output file is good. But when I activate the fontspec package, the compilation fails and shows the next error message:

! You can't use \char' after \the.
\EU1\i ->\char
"0131\relax
l.27 $\limf(x)$
I'm forgetting what you said and using zero instead.
Missing character: There is no ^^@ in font [lmroman10-regular]:mapping=tex-text!
Missing character: There is no ^^S in font [lmroman10-regular]:mapping=tex-text!


What is the problem and how can I solve it?

• I cannot reproduce using XeTeX, Version 3.14159265-2.6-0.99998 (TeX Live 2017). Find out whether you use the latest version of all packages (Which package version am I using?) and if not, update your system. – Henri Menke Jul 21 '17 at 3:22
• You should probably use unicode-math together with fontspec – MaxNoe Jul 21 '17 at 3:34
• EU1 in your error indicates an older tex system. Can you update? – Ulrike Fischer Jul 21 '17 at 6:44

I can reproduce the issue if I run the code with XeLaTeX on TeX Live 2014. If I also load unicode-math, the error disappears.

The problem is in how babel-spanish used to define the operator \lim in order to add the accent. In later releases of it, the issue has been removed.

A (not so) crude workaround if you can't upgrade:

\documentclass[letterpaper,reqno]{book}
\usepackage[spanish]{babel}
\usepackage{amssymb,amsmath,amsthm}
\usepackage{fontspec}

\makeatletter
\renewcommand\es@op@ac[1]{\textnormal{\'#1}}
\makeatother

\begin{document}

$\lim f(x)-\max g(x)+\min h(x)$

\end{document}
`

• Hi, Egreg. Your solution worked!!!!!!!! Thanks a lot for your help!!!! I tried to load the unicode-math package but (and I don't know why) that package and the other math packages (amsmath, amsfonts, etc) are not updated (they are 2013 versions) and my TeX Live is 2015. I'm trying to update them by console because the packages manager of my Opensuse Leap 42.2 only find the 2015 version of that packages. – Fabio Jul 21 '17 at 21:34