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.

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?)

share|improve this question
add comment

3 Answers

up vote 13 down vote accepted

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
\def\sp@n{\@@span\omit\advance\@multicnt\m@ne}
\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.

share|improve this answer
1  
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
add comment

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}

enter image description here

share|improve this answer
add comment

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}
share|improve this answer
add comment

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.