I found this macro from Voss' Math mode v2.47, page 21:

    \def\cr{\crcr\noalign{\kern 2\p@\global\let\cr\endline }}%
    \ialign {$##$\hfil\kern 2\p@\kern\@tempdima & \thinspace %
    \hfil $##$\hfil && \quad\hfil $##$\hfil\crcr\omit\strut %
    \hfil\crcr\noalign{\kern -\baselineskip}#2\crcr\omit %
    $\kern\wd\@ne\kern -\@tempdima\left\@firstoftwo#1%
      \if@borderstar\kern2pt\else\kern -\wd\@ne\fi%
    \global\setbox\@ne\vbox{\box\@ne\if@borderstar\else\kern 2\p@\fi}%
    \vcenter{\if@borderstar\else\kern -\ht\@ne\fi%
      \if@borderstar\kern-2\@tempdima\kern2\p@\else\,\fi\right\@secondoftwo#1 $%
    }\null \;\vbox{\kern\ht\@ne\box\tw@}%

Although the new \bordermatrix command works in my document, I want to know the meaning of every parts of this code snippets. Some of these macros could be found in macros2e, however, \m@th couldn't. So, what does \m@th mean, and which documentation should I read to gain knowledge about these macros?

2 Answers 2


The definition is found in latex.ltx:

% latex.ltx, line 481:

OK, it's just an abbreviation for \mathsurround\z@ which in turn is an abbreviation for


Now, what's \mathsurround? The syntax says it's a parameter, which has a length as value. It contains the amount of blank space that's inserted at either side of an inline math formula. Let's see a simple example:

An inline formula $E=mc^{2}$ and some text.

An inline formula $E=mc^{2}$ and some text.

enter image description here

Such a space is, technically, a kern; it will disappear at line breaks. Why is it in TeX to begin with? Some typographers use to add some space around formulas so as to detach them visually from the rest of the type block. This is not very common, though, and I know of no document class that sets a non zero \mathsurround. Of course, nobody would set it to a big value: maybe something around at most 2pt could be a choice.

When inline math mode is used for purposes different than inserting a formula in text, it's good practice to set \mathsurround to zero for avoiding spurious spaces. Thus, in the alignment that's build for \bordermatrix, it's set to zero in order not to add those kerns if the document sets \mathsurround. The same is done by the \@tabarray macro that's used for the array environment and in many other places where math mode is used, for instance in \textsuperscript:

% latex.ltx, line 6017:

A point to notice is that when TeX is typesetting a math formula, it will use the value of \mathsurround that's current when the closing $ is scanned.

The usual pattern is to say

\def\something#1{$\m@th<do something with #1>$}

although this opens the door for the possibility that some macro in #1 sets \mathsurround to another value. However this would surely be bad practice: the parameter should be set once and for all by the class or in the preamble. Note that $...$ makes a group, so doing \m@th inside the formula will not influence the value of the parameter outside this group. In the case of \textsuperscript there's an additional level of braces just for this purpose.

Is using \m@th necessary? Well, I'm guilty of not using it every time it could be necessary, trusting that nobody knows about \mathsurround or sets it to a nonzero value (which, in my opinion, makes for bad typography).

  • Oh, I think this is a better answer to my question. : )
    – Shadow
    Commented Jan 19, 2014 at 15:37

Macros containing @ in place of a are often found in the LaTeX kernel, so the document you need is source2e. You can also use \show to enquire about macros; thus



> \m@th=macro:
->\mathsurround \z@ .

\z@ is a kernel abbreviation for 0pt.

  • 2
    You could mention that \mathsurround is a primitive that by default (and almost always) is 0pt but it is used as extra space before and after all inline math. Commented Jan 10, 2014 at 13:31
  • Thank you for the answer and the hint on how to find these macros. Vote up and accept it. : )
    – Shadow
    Commented Jan 10, 2014 at 13:32
  • 1
    @Shadow quite possibly:-) Commented Jan 10, 2014 at 13:36
  • 2
    @DavidCarlisle Oh... It's the very Carlisle. Soooo excited! You know, the developers of LaTeX2e are some kind of super stars to me. (◑ω◑)
    – Shadow
    Commented Jan 10, 2014 at 13:42
  • 1
    Oh several of the LaTEX developers lurk here:-) Commented Jan 10, 2014 at 13:44

You must log in to answer this question.

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