I want to represent a 2D point in a space with SI units, something like (2,1mm; 2mm) or (2,1; 2)mm, whatever is considered best in the world of typography.

Is there a proper way to do this with with siunitx? Or do I just do

(\SI{2}{mm}; \SI{2}{mm})

The point of the question is that I don't know how to best represent a 2D point with units in text, so a predefined command with sane defaults would be useful.

Edit: I'm looking for an answear which adapts easily to different countries, without breaking consisntency.

  • 1
    A warm welcome to TeX.SE! – A Feldman Jun 21 '16 at 17:52

Here are two ways of writing them. The first one is more flexible, in that it sets a default output of millimetres, which could be changed by an optional parameter. The second one, is more simple, but it is also the only way I have ever seen it written in textbooks.

As for the confusing writing in countries where the decimal marker is a comma, in most books I have seen, they write the 2D and and 3D-points in the same way as they do in the rest of the world, changing the decimal marker to a dot. I don't know if that is true for all countries, but that is the practice in Norway. I have added code for this, using \sisetup.

It now uses \SIlist and \numlist as requested in comment. The \sisetup{}-command should possible be put inside the \NewDocumentCommand, with braces around the content, so that it only effect the command, and not a global change.

Of course, there is also the possibility of simply writing it out fully. For instance, something like:

A fence is 3 meters long and 5 meters wide.

It all depends on what it is exactly you are writing.


enter image description here


\sisetup{list-pair-separator= {; }}
    \mbox{(\numlist{#1;#2})}%% mboxes are here just to stop linebreak within a point.

We have a point at \Point{2.2}{3} and another point at \Point{5}{6.66}[\centi\metre].
Alternatively, one could write:
A fence is \SI{3.3}{\metre} long and \SI{5,7}{\metre} wide.
| improve this answer | |
  • I was looking for a more international answear. If one uses floating point numbers it can get ugly. Think \Point{2.1}{2.1} in a country (like my own) where decimal separators are ',' -> (2,1mm, 2,1mm). Also that's essentially my code wrapped in a command. But +1 for using \NewDocumentCommand for readability (didn't know it). – Olivetree Jun 21 '16 at 19:00
  • I used newDocumentCommand becouse it is easier to set up optional commands in it. It requires xparse, but most new packages use it anyway, I believe. I made an edit to the answer. – Runar Jun 21 '16 at 19:18
  • Hehe, that's cheating! By forcing the comma into a dot, you bring inconsistency to the document. But point taken, now the end-user does as he pleases with that. I'll wait a couple of days to see if someone comes up with a better answear, then mark this as solved. I don't what I want exists in the form I want :P – Olivetree Jun 21 '16 at 19:27
  • Well, It's one way of doing it. You can have a look at How do Europeans write a list of numbers with decimals?. You can change these settings to whatever fits your reader. – Runar Jun 21 '16 at 19:40
  • Because your link mentioned "list", I thought of SIlist: (\SIlist[list-pair-separator={, }, list-units=repeat]{2.1;2}{mm}) is closer to what I want, but list-pair-separator should have whatever the value of list-separator is, in this case. If you know how to do it, put in your answear and I'll accept it now :) Even if you don't, since your comment gave me the idea, update it, and I'll mark it. I prefer SIlist because it's more general, for other dimensions, and also has the options of (1mm, 1mm) or (1, 1)mm, etc, without having to write complex or many newcommands. – Olivetree Jun 21 '16 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.