17

Consider:

\documentclass{article}
\begin{document}

$\displaystyle\lim_{n\to\infty}$

\end{document}

This creates the typical limit symbol when n goes to infinity. However this code no longer works when I try to typeset 'lím', which is how it is written in Spanish.

\documentclass{article}
\begin{document}

$\displaystyle\lím_{n\to\infty}$

\end{document}

I get the error message ! Please use \mathaccent for accents in math mode.. Despite trying to use the command it does not fix the issue.

\documentclass{article}
\begin{document}

$\displaystyle\l\mathaccent{í}m_{n\to\infty}$

\end{document}
\documentclass{article}
\begin{document}

$\displaystyle\l\mathaccent{i}m_{n\to\infty}$

\end{document}

What is the right way to do this?

4

3 Answers 3

31

You can load babel with the spanish option. It changes \lim and other math operators to their Spanish versions.

\documentclass{article}
\usepackage[spanish]{babel}
\begin{document}

$\displaystyle\lim_{n\to\infty}$

\end{document}
19

If, for some reason, you can't load the babel package with the spanish option, you could redeclare the \lim macro as follows.

enter image description here

\documentclass{article}

\usepackage{amsmath} % for \DeclareMathOperator* macro
\let\lim\relax % release ("undefine") "\lim" as a macro name
\DeclareMathOperator*{\lim}{l\acute\i m}

\begin{document}
$\displaystyle\lim_{n\to\infty}$
\end{document}

For more information about creating accented characters in math and text mode see, e.g., this answer to the query Trying to use \~ to generate tilde symbol in math mode. (Shameless self-citation alert!)

0
14

There is no “magic rule” that allows you to type \lim to get the standard symbol and \lím to get the accent.

The command \lim has its own definition that eventually produces “lim” in upright medium font face, with appropriate positioning of the subscript, depending on the current math style. If you type \lím you get the same as

\l ím

because í cannot (in pdflatex) be part of a control sequence name (OK, this is not the full truth, but it's enough for this case). The error you get is because TeX doesn't like \l (the command to get ł in text) in math mode. You'd get a different error message if you had

\usepackage[T1]{fontenc}

What you need is to redefine \lim to get the accent. But, if you write in Spanish, you should do

\usepackage[T1]{fontenc}
\usepackage[spanish]{babel}

and the dreaded accents will appear.

Why “dreaded”? Because “lim” is not an abbreviation of a Spanish word, but started its life in mathematics from the Latin word limes. Similarly for other symbols.

Would you denote the iron element in chemistry with “Hi” instead of “Fe”? It's exactly the same. Symbols accepted in a scientific community are independent of the language.

This said, you can easily switch between the two possibilities.

\documentclass{article}
\usepackage[T1]{fontenc} % necessary for Spanish
\usepackage[spanish]{babel}

\usepackage{amsmath} % necessary for math

%\unaccentedoperators

\begin{document}

$\lim$\par
$\limsup$\par
$\liminf$\par
$\max$\par
$\min$\par
$a\equiv b\pmod{n}$

\end{document}

enter image description here

If you uncomment the \unaccentedoperators line, you get

enter image description here

Unicode engines

If you use either XeLaTeX or LuaLaTeX, you should use fontspec and remove \usepackage[T1]{fontenc}, of course.

There's no point in having a preamble that “works” for 8-bit and Unicode engines, because it is essentially impossible to have a document that runs unchanged in both situations except, perhaps, for very simple documents.

Well, one could think to do something like

\documentclass{article}
\usepackage{iftex}

\iftutex
  \usepackage{fontspec}
\else
  \usepackage[T1]{fontenc}
\fi

% other packages

%%% settings
\iftutex
  % settings for XeLaTeX or LuaLaTeX
\else
  % settings for pdflatex
\fi

\ifluatex
  % settings for LuaLaTeX
\fi

\ifxetex
  % settings for XeTeX
\fi

For instance, font loading for XeLaTeX might be different from LuaLaTeX (there are keys specific for either engine). However, my experience is that this is hopeless in most cases.

More important is to see whether you can do something about polyglossia instead of babel.

\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{amsmath} % necessary for math

\setmainlanguage[spanishoperators]{spanish}

\begin{document}

$\lim$\par
$\limsup$\par
$\liminf$\par
$\max$\par
$\min$\par
$a\equiv b\pmod{n}$

\end{document}

Here's an extract of the documentation to see what values spanishoperator can receive.

enter image description here

8
  • 4
    I think I’ll start denoting it by “græn” when writing in Danish, just to see people’s faces. ;-)
    – Gaussler
    Nov 4, 2022 at 8:50
  • 9
    I very much doubt that the OP is in a position to change the practices of Spanish-language publications, so the lengthy rant about how you believe accent marks shouldn't be used is irrelevant and should be excoriated.
    – A. R.
    Nov 4, 2022 at 13:42
  • 7
    @AndrewRay Two short paragraphs in a longer answer where a method to remove the accents by just uncommenting a command is suggested. Doesn't seem a “lengthy rant”.
    – egreg
    Nov 4, 2022 at 13:46
  • 2
    @AndrewRay We’re a very friendly place. Even if we think something should be excised, I’d hope we wouldn’t excoriate it!
    – Davislor
    Nov 5, 2022 at 7:48
  • 2
    One minor addendum: as you certainly know, T1 encoding should only be used with PDFLaTeX, and with LuaLaTeX or XeLaTeX, we should \usepackage{fontspec} instead. Kind of pedantic, but worth mentioning for any newbie copying-and-pasting the code.
    – Davislor
    Nov 5, 2022 at 7:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .