8

There are a few similar questions (see here and here) regarding overfull \hboxes in siunitx tables but neither solves/explains the following. Consider this MWE:

\documentclass{article}

\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}

\begin{table}[t!]%
\centering%
\sisetup{detect-none, mode=math, table-format=+1.1, table-auto-round}%
\begin{tabular}{ls[table-alignment=left]SSSS}%
\toprule%
A & \newton & 0.32 & 3.8 & -4.5 & -0.6 \\%
B & \newton & -0.12 & 1.1 & -1.6 & -1.0 \\%
C & \milli\metre & -2.45 & -7.0 & 2.3 & -4.3 \\%
\bottomrule%
\end{tabular}%
\end{table}%

\end{document}

When compiled with pdfLaTeX, overfull \hbox statements are present in the log file (these statements however are not picked up/flagged by TeXniCenter as warnings).

When the table-format option is altered to table-format=+2.1 the warnings are still present but when table-format=+3.1 the warnings suddenly disappear from the log file.

I have two questions:

  1. Why does table-format=+1.1 or +2.1 produce overfull \hbox messages in the log file but not table-format=+3.1? Have I misunderstood something obvious in the siunitx documentation?
  2. Why are the pdfLaTeX warnings not raised as LaTeX warnings? Is this something specific to TeXnicCenter or a more general behaviour?
  • Use table-format=-1.1 and the warnings disappear. – Thorsten Donig Nov 3 '13 at 13:22
  • So they do, which is a bit strange. Also, if I change every minus sign to a plus sign the warnings also disappear (with table-format=+1.1) but if I have just one minus sign I get a single warning. Perhaps it is a bug in siunitx? – luke Nov 3 '13 at 13:33
  • One of your columns has two digits after the ., so you need something like -1.2. – Joseph Wright Nov 3 '13 at 13:37
  • Even with table-auto-round? In reality the data in the table comes from a separate file and has many more decimal places than what I want shown in the final table. I like the convenience of being able to round the numbers off at the LaTeX-end rather than have to modify other data processing code. – luke Nov 3 '13 at 13:40
7

The table-format key is used to set up how much space siunitx reserves in a table column for numbers. As such, it should reserve enough space for the largest entry in that column. The format is the same as a number, and the input is processed by the same code. As such, if you need to reserve space for a sign then using - rather than + is recommended as with standard settings + will be 'thrown away' during parsing. Thus +1.1 will (probably) only reserve space for one digit before and one digit after the decimal marker, with none for the sign.

You will see the warnings disappear if you allow enough space, even if it's the 'wrong kind'. Thus something like -2.1 will reserve (in most cases) the same space as +3.1, as the entra 'digit' and the sign are the same width. Thus over-specifying digits may well remove warnings, but at the cost of loosing proper control of what is really going on.

The overfull box warnings will be in the log and come from TeX, not LaTeX. How they are then presented depends on the editor you use.

  • Thanks for the fast response Joseph. Is it stated anywhere in the documentation (which is excellent btw) that a - sign should be used to reserve space rather than a + sign? Most examples seem to use a + sign. – luke Nov 3 '13 at 13:37
  • @luke Possibly I need to tighten that up in the docs, or perhaps alter the behaviour (which is more an accident of implementation than any deliberate plan!). – Joseph Wright Nov 3 '13 at 13:39
  • No worries Joseph. With this question and answer now on stackexchange others should have no problems. – luke Nov 3 '13 at 13:42

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.