5

Please consider the following MWE:

\documentclass{article}
\usepackage[spanish]{babel}
\selectlanguage{spanish}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\begin{document}
Works: áéà

Does not work: \(\pmod1\)
\end{document}

The áéà text is copied correctly, but if I try to copy (mód 1) it says: (m´od 1).

Does anyone know why this happens? How is it solved?

Thanks!

manooooh
  • 3,203
  • 2
  • 21
  • 46
  • 1
    Possibly a viewer problem. Here it works fine (TL2018): https://hastebin.com/elulugejaw.shell – Henri Menke Aug 28 '18 at 02:52
  • @HenriMenke possibly... It works fine with your link. Something similar happens to me with the listings package. Any idea how to fix it? – manooooh Aug 28 '18 at 03:26
  • with recent miktex i obtain your result. for correct vowels in math operators names use \usepackage[spanish, english]{babel} \selectlanguage{spanish}. – Zarko Aug 28 '18 at 03:34
  • @Zarko thanks for your reply! I added english option but now it does not have accent, i.e. it displays as (mod 1) and copy as (mod 1) :(((. – manooooh Aug 28 '18 at 03:40
  • @manooooh, hm, i obtain accent character in the first text line, and correct in the second line (when use option english in babel. something weird happens :-( – Zarko Aug 28 '18 at 03:50
  • @Zarko yup, very weird. I have enumerate options (using my code) and the third level or something like that the enumeration format is I), II), ... (I would have liked them to appear in lowercase, but nvm). Anyway, when I add that option all the enumeration goes crazy and, for that example, the actual enumeration is i), ii), .... Weeeeird. – manooooh Aug 28 '18 at 03:54
  • 1
    At least partly this seems to be viewer dependent. I compiled your example with MikTeX's pdflatex (all packages updated yesterday) and got good copy text with SumatraPDF, but Adobe Reader gave me (mod 1), Firefox, Chrome and Edge all said (m ́od 1). (Of course this still shows that something is off, the consensus between viewers here is the wrong paste text, which is not good.) – moewe Aug 28 '18 at 04:23
  • @moewe a solution for an Adobe Reader user? Oh, it seems in most of viewers the text is wrong. – manooooh Aug 28 '18 at 04:24
  • 2
    On the whole it is rather surprising that some viewers get it right. spanish.ldf uses an math accent here. – Ulrike Fischer Aug 28 '18 at 07:29
  • 2
    @manooooh spanish.ldf is the file read by babel that provides support for the Spanish language. This redefines \pmod to do m\es@op@ac od and \es@op@ac o basically does \acute{o}, which will not use a precomposed character, whence the issue you have. – egreg Aug 28 '18 at 08:47
  • 2
    As I say elsewhere, “mod”, ”lim” and “sin” are symbols, not abbreviations. They come from the Latin name, so they should never bear accents. I know this position goes against established traditions, but they're wrong nonetheless. – egreg Aug 28 '18 at 08:59

1 Answers1

5

The babel module spanish.ldf redefines \pmod to do m\es@op@ac od and \es@op@ac is essentially \acute (with a correction for i in order to use the dotless i).

At the expense of a new math group, you can do

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

\usepackage{amsmath}

\makeatletter
\protected\def\es@op@ac#1{\csname math#1acute\endcsname}
\AtBeginDocument
 {%
  \DeclareSymbolFont{toneoperators}{T1}{\familydefault}{m}{n}%
  \SetSymbolFont{toneoperators}{bold}{T1}{\familydefault}{bx}{n}%
  \DeclareMathSymbol{\mathAacute}{\mathord}{toneoperators}{193}%
  \DeclareMathSymbol{\mathEacute}{\mathord}{toneoperators}{201}%
  \DeclareMathSymbol{\mathIacute}{\mathord}{toneoperators}{205}%
  \DeclareMathSymbol{\mathOacute}{\mathord}{toneoperators}{211}%
  \DeclareMathSymbol{\mathUacute}{\mathord}{toneoperators}{218}%
  \DeclareMathSymbol{\mathaacute}{\mathord}{toneoperators}{225}%
  \DeclareMathSymbol{\matheacute}{\mathord}{toneoperators}{233}%
  \DeclareMathSymbol{\mathiacute}{\mathord}{toneoperators}{237}%
  \DeclareMathSymbol{\mathoacute}{\mathord}{toneoperators}{243}%
  \DeclareMathSymbol{\mathuacute}{\mathord}{toneoperators}{250}%
 }%
\def\operator@font{\mathgroup\symtoneoperators}%
\makeatother

\begin{document}

mód lím máx

$\mod\quad\lim\quad\max$

\end{document}

enter image description here

egreg
  • 1,121,712