4 Answers
4

If you later decide to change formatting (adjusting spacing, etc.), here's an adaptation of Ryan Reich's answer to a similar question about vectors. It will at least give you a semantic command for coordinates:

Using \ensuremath in this context is very wrong. Try \coord{a,b,c}=\coord{1,2,3}+\coord{4,5,6} versus $\coord{a,b,c}=\coord{1,2,3}+\coord{4,5,6}$. This is a misuse of concept that easily leeds to bad typography.
–
yo'Jan 24 '13 at 11:06

If you mean the change in spacing when your first \coord line is rendered as three expressions with text-mode spacing around the = and +, I agree. If you mean something else, I don't yet understand.
–
Mike RenfroJan 24 '13 at 13:52

Yes, that is exactly what I mean. The macro \ensuremath is one of the things I really dislike in LaTeX. IMHO it should have been \ensur@math so that unaware users don't use it at all. --- Making math macro available in text mode is very wrong and dangerous, notice that no built-in macros (symbols etc.) don't allow it, nor do the ones you define using standard methods (\DeclareMathOperator, \DeclarePairedDelimiter etc.). It happens to everybody that he forgets to switch to mathmode and that's why it should raise an error.
–
yo'Jan 24 '13 at 16:01

I could be doing it wrong, but in the research proposal I've been writing for far too long, I make tons of use of \ensuremath macros. For one, because I've tried to train myself to use \( and \) instead of '$' and '$', and defining macros so I can more easily write things like sum of an elastic component (\Jel) and a plastic component (\Jpl) or \( \J = \Jel + \Jpl \) with the two values defined as macros like \newcommand{\Jel}{\ensuremath{\J_\textnormal{el}}\xspace} -- is there a better option I've missed somewhere?
–
Mike RenfroJan 24 '13 at 19:50

Since I would not put standalone \Jel in parentheses, I would end with \(\Jel\), which is not that bad. And \xspace is exactly the second thing I don't like, exactly because it means "losing of control". It's IMHO much more convenient and consistent to write \xyz{} instead of relying on \xspace and having to remember whether I put it in the command or not. Of course, in your case, I would have \(\JpL\) and no {} not \xspace.
–
yo'Jan 26 '13 at 23:50

Using \ensuremath in this context is very wrong. Try \coord{a,b,c}=\coord{1,2,3}+\coord{4,5,6} versus $\coord{a,b,c}=\coord{1,2,3}+\coord{4,5,6}$. This is a misuse of concept that easily leeds to bad typography.
–
yo'Jan 24 '13 at 11:06

@tohecz: This depends on the point of view. The problem of your “counter-example” isn't \ensuremath for \coord, but typesetting a formula containing + and = outside a math environment.
–
simon04Feb 4 '13 at 9:35

Which has never happened to any of us of course. The LaTeX error Missing $ inserted (when you use math-mode macro in text-mode) has rescued me many times, and you, by using \ensuremath get rid of this rescue system.
–
yo'Feb 4 '13 at 9:41