Well I've been working in some tables and for the number alignment I normally use the siunitx
package since Mico helped me with this question.
But I've had in these new tables an error I don't understand how to solve.
siunitx error: "invalid-number" Invalid numerical input 'e'.
For immediate help type H <return>. \end{tabularx}
I found these questions about it: question 1 and question 2. Unfortunately it isn't the same case, and I haven't found clues leading me to the solution.
My MWE is:
\documentclass[fontsize=10pt,paper=letter,headings=small,bibliography=totoc,DIV=9,headsepline=true,titlepage=on]{scrartcl}
\usepackage[spanish,mexico]{babel}
\usepackage{xspace}
\usepackage{xkeyval}
\usepackage{array,multirow,multicol,rotating,tabularx,ragged2e,booktabs}
%\newcolumntype{Y}{>{\RaggedRight\arraybackslash\hspace{0pt}}X}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash}X}
%\newcolumntype{C}{>{\centering\arraybackslash\hspace{0pt}}X}
\usepackage{rotating} % Paquete para rotar objetos flotantes
\usepackage{colortbl} % Paquete pata colorear tablas
\usepackage[per-mode=symbol]{siunitx} % Paquete para insertar unidades
\sisetup{
output-decimal-marker = {.},
group-minimum-digits = 4,
range-units = brackets,
list-final-separator = { \translate{and} },
list-pair-separator = { \translate{and} },
range-phrase = { \translate{to (numerical range)} },
}
\ExplSyntaxOn
\providetranslation [ to = Spanish ]
{ to~(numerical~range) } { a } % substitute the right word here
\ExplSyntaxOff
\begin{document}
\begin{table}[htbp]
\centering
\caption{Mercado de energía eléctrica en Norteamérica}
\label{tab:emna}
\begin{tabularx}{\linewidth}{@{}lYrYrYrYr @{}}
\toprule
País & Producción [\si{\giga\watt\hour}] & Fecha & Consumo [\si{\giga\watt\hour}] & Fecha & Exportaciones [\si{\giga\watt\hour}] & Fecha & Importaciones [\si{\giga\watt\hour}] & Fecha \\
\midrule
Canadá & 612000 & 2007 & 530000 & 2006 & 50120 & 2007 & 19660 & 2007 \\
Estados Unidos & 4167000 & 2007 & 3892000 & 2007 & 20140 & 2007 & 51400 & 2007 \\
México & 243300 & 2007 & 202000 & 2007 & 1278 & 2007 & 482.2 & 2007 \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
I try to use S
column-type in the middle and right columns but I can't because the error mentioned before. I tried using simply S
column without success and later S[table-format=5.0]
but that didn't work. What's wrong with my tables?
Update
Although both answers were very interesting and useful, I'm afraid my problem persists. I can't add to my tables columns type S
and I need them.
Now I add a table that currently work with the same problem, in which I used the column type Y
meanwhile but the result hasn't been satisfactory.
I guess one of the packages in my preamble is responsible, see if I can detect itbecause the MWE seems to work smoothly.
S
columns and escape the column headers by adding brace groups then all is fine. Can you edit in a MWE that actually does show the issue, otherwise it will be impossible to solve.tabularx
', or at least 'Don't expectsiunitx
columns to mess about with spacing'. They are designed to be as far as possible the size of the content.