# What is the correct way to write a set of multiple variables or the multiples variables of a function in LateX 2e or with standard package?

Which of it is the correct way in English typography, with LaTeX?

\documentclass{article}
\begin{document}
$f(x,y)= \ldots$

$f(x,\ y) = \ldots$

$f(x,\,y) = \ldots$

The coordinates $(x,y,z,t)$ \ldots

The coordinates $(x,\ y,\ z,\ t)$ \ldots

The coordinates $(x,\,y,\,z,\,t)$ \ldots

The coordinates $(x^0,x^1,x^2,x^3)$ \ldots $\leftarrow$ seems bad.

The coordinates $(x^0,\ x^1,\ x^2,\ x^3)$ \ldots

The coordinates $(x^0,\,x^1,\,x^2,\,x^3)$ \ldots
\end{document}


I write "seems bad" in the antepenultimate line because I feel same space before and after the commas.

Is there a package that automatize it? E.g a package which provide a command like \mycoord which we can use as \mycoord{x,y,z,t} and which add the correct spaces between comma in the output?

I'm aware of this question: Typesetting coordinates but answers are not clear about the spacing between the coordinate, and moreover, I don't want an answer with LaTeX 3, unless it's in a not so recent package (for compatibilities with a bit old system I don't control).

Edit: adding the comparison with a negative space before comma, in the case with variables with exponents.

\documentclass{article}
\begin{document}
1) The coordinates $(x,y,z,t)$ \ldots

2) The coordinates $(x^0,x^1,x^2,x^3)$ \ldots

3) The coordinates $(x^0\!,x^1\!,x^2\!,x^3)$ \ldots
\end{document}


Does the third seems better than the second?

Second edit:

How I see the spacing (probably wrongly..., but the third seems a little better than the second, but perhaps the negative space is a little too big) :

• Remove all \, bits and “backslash-space”. Now you're done. – egreg Jun 24 at 14:50
• I would not add the thin space, just use the standard comma, so no extra macros are needed – David Carlisle Jun 24 at 14:58
• @DavidCarlisle But doesn't the antepenultimate line be odd in a typographic eye? Seems to be too space before the commas, as the comma is in the middle of the previous and the next object. In contrast, with $(x,y,z,t)$, there is more space after the comma than before. Must I keep juste the comma in this case, or add a negative space \! before the comma in this specific case? – quark67 Jun 24 at 15:10
• @quark67 just let LaTeX do its thing, don't fight it. This is exactly the reason why the comma in math mode has a bigger spacing after it and one have to some something extra to use the comma as a decimal marker. – daleif Jun 24 at 15:16
• no the line marked bad looks much better than the following line. – David Carlisle Jun 24 at 15:42

The package semantex (disclaimer: I am the author) can do many things like this in a customizable way. Unfortunately, it is a relatively recent package, but I believe it should work with older versions of LaTeX3, too, though I have not checked this.

\documentclass{article}

\usepackage{amsmath,semantex}

\NewVariableClass\MyVar

\NewObject\MyVar\mycoord[
left par=(,
right par=),
set arg sep={,},
set arg dots=\dotsc,
]

\begin{document}

$\mycoord{x^0, x^1, ... , x^p}$

\SetupObject\mycoord{
% Let’s change the settings:
set arg sep={,\,},
}

$\mycoord{x^0, x^1, ... , x^p}$

\end{document}


Otherwise, for a more portable solution, you can try editing this answer by egreg. As he notes in the comments, the comma can easily be replaced by anything else. And I believe this should work perfectly well with much older versions of LaTeX3.

• Useful package. But I need to find the proper spacing (see my edited question). Perhaps with an adjusted set arg sep={\!,} (\!seems to be a little to big negative space). Perhaps I'm completely wrong, but my eye is not completely satisfied with the default LaTeX (strange because LaTeX has hight typography default settings). – quark67 Jun 24 at 16:37