# Error message: ! Use of \bbm does not match its definition

I have the following minimal working example -- why does \def\bbm15 not work?? The error I get is

*File: umsb.fd 2013/01/14 v3.01 AMS symbols B
)
! Use of \bbm doesn't match its definition.
l.16 \bbm1
5 %this generates an error!
?
! Emergency stop.
l.16 \bbm1
5 %this generates an error!
End of file on the terminal!*


Minimum working example:

\documentclass{article}
\usepackage{mathtools}
\usepackage{amsmath,amsthm,amsfonts}

\def\bbm15{\renewcommand{\arraystretch}{1.5}\begin{bmatrix}}
\def\bbm20{\renewcommand{\arraystretch}{2.0}\begin{bmatrix}}
\def\ebm{\end{bmatrix}}

\begin{document}
$$X = %\bbm20 %this works fine! %\bbm15 %this generates an error! \renewcommand{\arraystretch}{1.5}\begin{bmatrix} %this works fine! X_{11} & X_{12} & \cdots & X_{1p} \\ X_{21} & X_{22} & \cdots & X_{2p} \\ \vdots & \vdots & \ddots & \cdots \\ X_{n1} & X_{n2} & \cdots & X_{np} \ebm .$$

\end{document}

• Welcome to TeX.SE! LaTeX and TeX command names should not include both letters and numbers. – Mico Nov 15 '17 at 11:13

\def\bbm15{..}

defines \bbm such that it must be followed by 15

\def\bbm20{..}

redefines \bbm so that it must be followed by 20

so after this definition \bm15 will give the error shown in the question.

If you use \newcommand you will be warned of redefinitions

\newcommand\bbmA{\arraystretch}{1.5}\begin{bmatrix}}
\newcommand\bbmB{\arraystretch}{2.0}\begin{bmatrix}}


then you can use \bbmA and \bbmB but probably I would suggest

\newcommand\bbm[1][1.5]{\arraystretch}{#1}\begin{bmatrix}}


and use \bbm and \bbm[2]

The reason why \bbm20 appears to "work fine", as you put it, whereas \bbm15 does not, is coincidence; David's answer provides a more thorough explanation. For sure, if you reverse the ordering of the two \def instructions, i.e., if you define \bbm20 before rather than after \bbm15, you'll find that \bbm20 throws an error whereas \bbm15 now "works fine". (If you had used \newcommand instead of \def to create the macros \bbm15 and \bbm20, you would have received some useful messages alerting you to the syntax error issue.)

What's going on? In general, names of TeX and LaTeX macros must consist either of uppercase and lowercase letters (A to Z and a to z, no other character types allowed) or a single non-letter character. Thus, the macro names \bbm20 and bbm15 simply aren't valid, from a syntactic point of view, for use in a LaTeX document.

If you must create separate macro names, I would like to suggest you use \bbmXX and bbmXVX, i.e., employ uppercase Roman "numbers" instead of arabic numerals.