Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

What is the \mathop command meant to be, officially?

I see it used in indexes of sums and limits to improve the spacing, e.g.

\sum_{n\mathop = 1}^\infty a_n

Why doesn't it just format it like this automatically? It looks so much better.

share|improve this question
3  
You (or they) are doing it wrong... that is, the use of \mathop. Indices are set with different spacing around the relations/operators. You can use n\,=\,1 to get the same effect. –  Werner Apr 16 at 5:57
    
@Werner Why exactly is it wrong? Is this using \mathop or trying to change the spacing at all? –  LTS Apr 16 at 5:59
1  
\mathop is meant to temporarily define a math operator (or function, say, like sup or inf or argmax/argmin), and here = is a relation. So, while the spacing better spacing may be achieved, the usage is technically incorrect. –  Werner Apr 16 at 6:05

3 Answers 3

up vote 6 down vote accepted

TeX sets \thickmuskip between the relational operator and most other math atoms in styles \displaystyle and \textstyle, but no space in script styles \scriptstyle and \scriptscriptstyle.

A \thinspace is also inserted in script styles between an operator atom (\mathop) and an ordinary atom (\mathord). Thus

\sum_{n \mathop{=} 1}

gets you the desired spacing:

mathop =

However:

  • The relational symbol becomes an operator, a violation of a clean markup.
  • The spacing is too small in \displaystyle and \textstyle.
  • \mathop vertically centers the symbol, e.g.:

    \sum_{n \mathop{.} 1}
    

    cdot

    The dot is moved to the math axis and becomes a "\cdot".

    This is not a problem for the equals sign, because this is usually already centered around the math axis.

The spacing can be manually fixed by adding \, as suggested in Werner's comment:

\sum_{n \,=\, 1}

thin spaces

Advantage:

  • It's more to the point.
  • Shorter for typing.

A small disadvantage remains:

  • Too large space in \displaystyle and \textstyle

There is a trick to circumvent the latter: \nonscript suppresses the following space in the script styles.

\documentclass{article}

\newcommand*{\mrel}[1]{%
  \mskip\thinmuskip
  \nonscript\mskip-\thinmuskip
  \mathrel{#1}%
  \mskip\thinmuskip
  \nonscript\mskip-\thinmuskip
}
\begin{document}
\[ \sum_{n \mrel= 1} \mrel= 1 \]
\end{document}

\mrel

\thinmuskip is added in script styles, otherwise it is canceled by -\thinmuskip.

LuaTeX

In LuaTeX the spacings between the math atoms can be configured very deeply. Also the cramped styles are available as commands. Cramped styles are used, if something is above the expression (denominator, \sqrt, ...). Then superscripts are lowered a bit. Cramped style is used in the subscript of \sum.

The following example configures a thin space between math atoms in \scriptstyle and cramped \scriptstyle, where a thick space would be set in \textstyle or \displaystyle.

 \documentclass{article}

\usepackage{ifluatex}
\makeatletter
\ifluatex
  \def\@tempa#1#2#3{%
    \csname luatexUmath#1#2spacing\endcsname\luatexcrampedscriptstyle=#3\relax
    \csname luatexUmath#1#2spacing\endcsname\scriptstyle=#3\relax
  }%
  \@for\@tempb:={ord,op,close,inner}\do{%
    \@tempa\@tempb{rel}\thinmuskip
  }%
  \@for\@tempb:={ord,op,open,inner}\do{%
    \@tempa{rel}\@tempb\thinmuskip
  }%
\fi
\makeatother

\begin{document}
\[ \sum_{n = 1}^{n = 1} \]
\end{document}

LuaTeX

Remarks:

  • LuaLaTeX uses a prefix luatex for new LuaTeX commands to avoid name clashes with existing macros.
  • There are 16 settings. The \@for loops avoid a long list of assignments.
share|improve this answer
    
Thanks! Would using \mathop also be incorrect in this context: \lim_{x\mathop \to \infty} f(x) ? I will use \, from now on, I don't actually see a difference in displaystyle. –  LTS Apr 16 at 7:47
    
@Oliver: At least \to is usually already vertically centered. In \displaystyle the space around = as \mathrel is larger than around = as \mathop. –  Heiko Oberdiek Apr 16 at 7:58

as stated by Werner in a comment, \mathop is intended to define operators like lim et al., while = is a relation.

as for the spacing, that was determined through knuth's examination of numerous examples published in the most carefully typeset journals of the early 20th century. these publications are cited in various writings by knuth. i recommend particularly his Gibbs lecture, published in the bulletin of the american mathematical society. (i'm not in a position to give a link right now, but it should be easy to find using google.)

Edit: Here is the link http://www.ams.org/journals/bull/1979-01-02/S0273-0979-1979-14598-1/S0273-0979-1979-14598-1.pdf

share|improve this answer
    
Can't find it on google or youtube unfortunately - would like to see it. –  LTS Apr 16 at 8:01
    
this is how to find it. (the tool i'm using doesn't show full urls, so i have to give a recipe.) go to ams.org/bull and choose "all available volumes". then choose year 1979, volume 1, issue 2, and search through the contents list for the article by knuth. (if someone can put the correct url into my answer, please do; i won't be able to until next month.) –  barbara beeton Apr 16 at 8:14
    
@Oliver -- thanks for the link. –  barbara beeton Apr 16 at 8:30

Here are four strategies. The first is what I like the best.

\documentclass{article}
\usepackage{amsmath}
\newcommand{\su}[1]{%
  \text{\thickmuskip=3mu$#1$}%
}


\begin{document}
\begin{alignat*}{2}
&\text{Normal: }   && \sum_{k=1}^{m}a_{k}\\
&\text{Modified: } && \sum_{\text{$k=1$}}^{m}a_{k}\\
&\text{Thin space: } && \sum_{k\,=\,1}^{m}a_{k}\\
&\text{Command: } && \sum_\su{k=1}^{m}a_{k}
\end{alignat*}
\end{document}

enter image description here

share|improve this answer
    
Thanks. It's not as obvious close up but from a distance it seems obvious that the third is superior to the first, e.g. quickpic.info/z/i6.jpg –  LTS Apr 16 at 12:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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