TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it a bug in the numprint package .. or maybe a missing feature? I can't align on the plus/minus sign in tabular environments, padding numbers with spaces.


\nplpadding[\ ]{4}
  -940    & +1000   \\
  +952.38 & -1000 \\ \midrule
  +12.38 &     0 \\


Any hint welcome.

share|improve this question
I do not know the numprint package, but siunitx offers you aligning at the decimal sign. – Qrrbrbirlbel Oct 14 '12 at 16:32
In fact, numprint works correctly with the alignment at the decimal sign. The problem is the plus/minus signs ... – green diod Oct 14 '12 at 16:37
First instinct: \nplpadding[\hphantom{0}]{4}, but it fails. (A space has not the same width as a digit.) – Qrrbrbirlbel Oct 14 '12 at 16:58
I came to the same conclusion about the space width. Now, how to tell \nplpadding to use a blank character the same width as the surrounding digits? – green diod Oct 14 '12 at 17:01
I can only offer a manual solution (separate columns for + and $-$): {*{2}{r@{}N{4}{2}}} – Qrrbrbirlbel Oct 14 '12 at 17:26
up vote 2 down vote accepted

I don't know about the “good ol’ plainTeX” way, but you can use an additional column that is right aligned (as + and have the same horizontal width the alignment doesn't really matter).


  $-$ & 940    &  +  & 1000 \\
   +  & 952.38 & $-$ & 1000 \\ \midrule
   +  &  12.38 &     &    0 \\

The padding is still be done by numprint but with @{} we force that + and are being typeset without any further space.

As this is probably needed a lot more times, with the use of the array package we define another column specification:


It can be used, for example, as M{4}{2}.

Typing all those ampersands is a bit tedious so we make + and - active so that they insert the ampersands on its own, but we don't want this to affect the whole document, only our special tabular should have this effect, therefore I defined a new ntabular environment that is basically just a wrapper for a tabular environment with active + and -.

(I didn't introduce another character that “automatically” expands to &, because … you can just use &, can't you? Unfortunatly, this is still needed if you have no sign in front of a number.)


Is it safe to use + and -?
   - 940    &  + 1000 \\
   + 952.38 &  - 1000 \\ \midrule
   +  12.38 &  &    0 \\

Is it safe to use + and -?


enter image description here

share|improve this answer
Why is there more space after the signs in the left hand column than the right hand column? – Thruston Oct 15 '12 at 16:05
@Thruston Because the first N column uses 4 digits before the decimal point, too. Better use would be {M{3}{2} M{4}{0}}, I guess, but I didn't want to change the OP's column specification. – Qrrbrbirlbel Oct 15 '12 at 16:16
I like your solution. For the coumn specs, I wanted it simple. But indeed, I shouldn't be so lazy and adjust each column appropriately ;) – green diod Oct 16 '12 at 8:44

Your Answer


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.