[TxMt] Re: Problem with snippet

Édouard Gilbert edouard.gilbert at eleves.bretagne.ens-cachan.fr
Tue May 8 11:29:49 UTC 2007


> What about \newcommand{\um}{$\mu m$}?

If it's LaTeX, I'd suggest
\newcommand{\um}{%
	\ensuremath{%
		\mu \textrm{m}%
	}%
}
instead.

Or perhaps even better
\newcommand{\micro}[1]{%
	\ensuremath{\mu \mathrm{#1}}%
	\xspace%
}
Of course, you need to add \usepackage{xspace} in your header.

That way, you'll just have to type \micro{some unit} to get the  
expected result. You can even drop the {} and just add a space if the  
unit is a single character. If you're really lazy, you can choose a  
shorter name (such as \u, if available) for the command.

Or use a snippet:
\micro{$1}$0

That would make your LaTeX code easier to read, in my opinion. And  
the command will work inside or outside math environments.



More information about the textmate mailing list