The amsmath package secures away the original \mathcode of the minus and equal signs, and subsequently uses the saved values in the macros that provide the extensible arrows (e.g., \leftarrowfill@). Indeed, at lines 893–900 of amsmath.sty we read


Why does it do so? What problem are the package authors trying to avoid here?

  • 1
    It's for \operatorname and related things. – egreg Feb 4 '17 at 17:37
  • @egreg: I see; but why \std@equal, then? As far as I can see, \newmcodes@ does not redefine the \mathcode of =. – GuM Feb 4 '17 at 17:47
  • 2
    I guess it's for symmetry. I'm more concerned with the redefinition of \std@minus in \newmcodes@, which I deem wrong and, indeed, it can break in certain circumstances, see tex.stackexchange.com/a/299805/4427 – egreg Feb 4 '17 at 17:52
  • @egreg: Well, now I have another question: I thought half an hour, and I cannot see why \std@minus is redefined again inside \newmcodes@! – GuM Feb 4 '17 at 18:24

diffs-m.txt contains the remark

---Changed \relbar to use \std@minus---otherwise \underleftrightarrow works poorly in a \DeclareMathOperator definition.

and trying this out one can see the problem:









enter image description here

  • Yes, this is essentialy the same answer that @egreg gave in his comment, but the reference to the change log is undoubtebly more useful, and amounts to a “positive” answer. :-) – GuM Feb 5 '17 at 13:14

the comment in the file amsmath.dtx reads thus:

The minus sign used in constructing these arrow fills is smashed so that superscripts above the arrows won't be too high. This primarily affects the \xleftarrow and \xrightarrow arrows.

since this file has been processed into a pdf file and is included in tex live, you can look at the details by asking for texdoc amsmath.pdf.

implicit in this setting is the knowledge that the minus sign in computer modern has the same height as the plus, which would certainly affect the positioning of superscripts unless adjusted.

although not commented explicitly, the equal sign is used as the extender for two-shaft arrows.

  • Of course, I had already read, as carefully as I could, the comments in amsmath.dtx before asking this question, but unfortunately they do not explain, as I said in my question, what problem the authors are trying to avoid. @egreg has answered in his comments, and, by the way, I think that the whole community would benefit if he decided to write a comprehensive answer. – GuM Feb 4 '17 at 17:56
  • Let me clarify that I was not asking the reason of the smashing applied to the minus sign: that has always been clear to me. What I was asking was, why do one need to store away the \mathcode value? – GuM Feb 4 '17 at 18:10
  • @GustavoMezzetti -- that's a question for the creators of amsmath; it wasn't done that way in ams-tex, so it was added when that was "transformed". i'll ask. – barbara beeton Feb 4 '17 at 18:40
  • Thank you for your interest in this question. Actually, if I look at amstex.tex, I cannot find a redefinition of \relbar, so I infere that it uses the definition inherited by plain.tex, which is \def\relbar{\mathrel{\smash-}} and thus makes no mention of \std@minus. – GuM Feb 4 '17 at 19:08
  • 2
    @barbarabeeton fairly sure you need to ask Michael .. and none of us want to do that just yet. This is not from the days when I and Rainer reimplement amstex for LaTeX, it must have come later – Frank Mittelbach Feb 4 '17 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.