# \span as a math operator

I'd like \span to be a math operator (for the span of a set of vectors), but apparently it's already a TeX command. What do you guys recommend I do instead? (I don't really want a strange capital \Span, or some other odd variant... but I'm guessing it's a bad idea to redefine \span?)

-
As a general practice, I always use upper case to define my own macros. So I use \SPAN. This avoids collision with the internal macros. Since all such macros that I define are upper case, it does not appear strange :-). –  Aditya Apr 28 '14 at 17:30

Yes, it's a bad idea: \span is a primitive command used in \multicolumn.

Actually \span appears only once in the LaTeX kernel, so it's possible to say

\makeatletter
\let\@@span\span
\makeatother

\renewcommand{\span}{...}


but other packages might rely on the primitive meaning of \span. If you like to live dangerously…

There is indeed an important package that relies on \span and it is amsmath, which in one of its most important routines uses that primitive. When LaTeX3 will be released, all primitive commands will have received new names and LaTeX3 packages will not be using \span anymore; till then, choose another name such as \Span or \vspan.

-
Seems it has more quibbles with amsmath: redefining \span gets "Missing # inserted in alignment preamble." and then a bunch of "Extra alignment tab". Perhaps this is a terrible idea after all. Suggestions on naming for a new command? –  jtbandes Nov 1 '11 at 1:09
(That's when I try to use the align* or any other amsmath environment.) –  jtbandes Nov 1 '11 at 1:35
@jtbandes: Perhaps add more context to the macro name: \vecspan or \vectorspan. –  Werner Nov 1 '11 at 5:06
Hmm, it seems another advantage of future LaTeX3 –  Leo Liu Nov 1 '11 at 16:09
@LeoLiu Yes, this is surely an advantage: primitives won't be accessible by their original names (unless one uses \primitive, with its new name, of course); there will be less risks of redefining something important. –  egreg Nov 1 '11 at 16:24

Since \span is already a well-established macro, it can't be a good idea to re-use the word for a new command. Are \spn and \Span really that bad as alternatives to \span? The following MWE, which uses the amsmath package and its DeclareMathOperator command, illustrates the usage of the macro called \spn:

\documentclass{article}
\usepackage{amsmath,amsfonts}
\DeclareMathOperator{\spn}{span}
\renewcommand{\vec}[1]{\mathbf{#1}}
\begin{document}
Let $\vec{e}_i = (0,\dots,0,1,0,\dots,0)'$ be an $n\times 1$ column
vector with $1$ in the $i$-th position and $0$ in all others. Then
$\spn\{\vec{e}_1,\vec{e}_2,\dots,\vec{e}_n\} = \mathbb{R}^n$.
\end{document}


-

Consider using spann or spanset, I would prefer the latter with a short macro.

\documentclass{article}
\usepackage{amsmath,amsfonts}
\DeclareMathOperator{\spann}{span}
\newcommand\spanset[1]{\ensuremath\spann(#1)}
\begin{document}
$\spann(S) = \spann(v_1,\dots,v_r) = \{ {\lambda _1 v_1 + \dots + \lambda _r v_r \mid \lambda _1 , \dots ,\lambda _r \in \mathbf{K}} \}$

$\spanset{S}=\spanset{v_1,\dots,v_r}= \{ {\lambda _1 v_1 + \dots + \lambda _r v_r \mid \lambda _1 , \dots ,\lambda _r \in \mathbf{K}} \}$
\end{document}

-
\operatorname{span}


This works well.

-
welcome to TeX.SX! Explaining a bit more about this solution or showing a complete minimal working example (MWE) would greatly improve the answer. –  Adam Liter Apr 28 '14 at 16:34