siunitx 오류: "invalid-number" 잘못된 숫자 입력 'e'

siunitx 오류: "invalid-number" 잘못된 숫자 입력 'e'

글쎄요, 저는 일부 테이블에서 작업해 왔으며 숫자 정렬을 위해 일반적으로 다음을 사용합니다.siunitx Mico가 저를 도와준 이후로 일반적으로 패키지를 사용합니다.이 질문.

하지만 이 새 테이블에는 해결 방법을 이해할 수 없는 오류가 있었습니다.

siunitx error: "invalid-number" Invalid numerical input 'e'. 
For immediate help type H <return>. \end{tabularx}

나는 그것에 대해 다음과 같은 질문을 발견했습니다.질문 1그리고질문 2. 불행히도 그것은 같은 경우가 아니며 해결책으로 이끄는 단서를 찾지 못했습니다.

내 MWE는 다음과 같습니다.

\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}

S가운데 열과 오른쪽 열에 열 유형을 사용하려고 하는데 앞에서 언급한 오류로 인해 사용할 수 없습니다. 나는 S성공하지 못한 채 단순히 열을 사용해 보았지만 나중에 S[table-format=5.0]는 작동하지 않았습니다. 내 테이블에 무슨 문제가 있나요?


업데이트

두 답변 모두 매우 흥미롭고 유용했지만 문제가 지속되는 것 같습니다. 내 테이블 열 유형에 추가할 수 없으며 S해당 항목이 필요합니다.

이제 현재 동일한 문제를 해결하는 테이블을 추가합니다. 그 동안 열 유형을 사용했지만 Y결과가 만족스럽지 않았습니다.

내 서문에 있는 패키지 중 하나가 책임이 있는 것 같습니다. MWE가 원활하게 작동하는 것 같으니 이를 감지할 수 있는지 확인하세요.

답변1

(OP가 MWE의 테이블을 변경한 후 답변을 다시 작성했습니다.)

다음 솔루션을 사용하면 S4개의 "GWh" 열에 대한 열 유형을 사용할 수 있습니다.그리고환경 을 사용할 수 있습니다 tabularx(테이블 너비가 와 같도록 보장 \linewidth). 트릭은 S숫자에 를 사용하고 헤더에 C(의 중앙 버전 ) 을 사용하는 것으로 구성됩니다 .X

내가 테이블 헤더를 재구성한 것을 볼 수 있을 것입니다. 원래 설정에서는 Producción, Consumo, Exportaciones및 4개의 중요한 헤더 단어 모두에 줄 바꿈이 필요합니다 Importaciones. 그런 단어에는 하이픈을 (가능한 한) 피하는 것이 좋다고 생각합니다. 헤더 주위에 대괄호를 남겨 두었습니다 GWh. 그러나 필요하지 않을 수도 있습니다.

(프리앰블 코드를 단순화하고 합리화하기 위해 테이블 ​​생성에 필수적이지 않은 것으로 보이는 패키지도 모두 제거했습니다.)

여기에 이미지 설명을 입력하세요

\documentclass[fontsize=10pt,paper=letter,headings=small,bibliography=totoc,
         DIV=9,headsepline=true,titlepage=on]{scrartcl}
\usepackage[spanish,mexico]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{tabularx,booktabs}
\newcolumntype{C}{>{\centering\arraybackslash}X} % centered version of "X" column type
\newcommand\mc[1]{\multicolumn{2}{@{}C@{}}{#1}}  % shortcut macro

\usepackage{siunitx} % Paquete para insertar unidades
\sisetup{
    per-mode = symbol,
    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}
\caption{Mercado de energía eléctrica en Norteamérica}
\label{tab:emna}
\begin{tabularx}{\linewidth}{@{} l
                  *{2}{S[table-format=7.0]r}
                       S[table-format=5.0]r
                       S[table-format=5.1]r @{}}
\toprule
País & \mc{Producción} & \mc{Consumo} & \mc{Exportaciones} & \mc{Importaciones} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7} \cmidrule(l){8-9} 
& [\si{\giga\watt\hour}] & Fecha & [\si{\giga\watt\hour}] & Fecha 
& [\si{\giga\watt\hour}] & Fecha & [\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} 

부록: 동일한 표이지만 헤더 자료를 재구성하지 않았습니다. Y4개의 헤더 셀에 열 유형이 사용된다는 점을 제외하면 코드는 위와 동일합니다 .

여기에 이미지 설명을 입력하세요

....
\newcolumntype{Y}{>{\hspace{0pt}\RaggedRight\arraybackslash}X} % allow hyphenation
....
\begin{table}[htbp]
\setlength\tabcolsep{4pt}
\caption{Mercado de energía eléctrica en Norteamérica}
\label{tab:emna}
\begin{tabularx}{\linewidth}{@{}l
      *{2}{S[table-format=7.0]r}
           S[table-format=5.0]r
           S[table-format=5.1]r @{}}
\toprule
País 
& \multicolumn{1}{Y}{Producción [\si{\giga\watt\hour}]} & Fecha 
& \multicolumn{1}{Y}{Consumo [\si{\giga\watt\hour}]} & Fecha 
& \multicolumn{1}{Y}{Exportaciones [\si{\giga\watt\hour}]} & Fecha 
& \multicolumn{1}{Y}{Importaciones [\si{\giga\watt\hour}]} & Fecha \\
\midrule
....

답변2

당신은 필요하지 않지만 tabularx주식은 tabular*. 사용 가능한 공간에 테이블을 더 잘 맞추기 위해 "Estados Unidos"를 "EUA"로 축약했습니다.

열의 숫자가 아닌 입력은 S중괄호로 작성되어야 합니다. 이런 방식으로 에서는 siunitx텍스트를 숫자로 해석하려고 시도하지 않으며 이는 "Exportaciones" 셀에 오류 메시지가 나타나는 이유입니다.

\documentclass[
  fontsize=10pt,
  paper=letter,
  headings=small,
  bibliography=totoc,
  DIV=9,
  headsepline=true,
  titlepage=on
]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish,mexico]{babel}  
\usepackage{booktabs} 

\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)} },
}

\begin{document}

\begin{table}[htbp]
\centering
\caption{Mercado de energía eléctrica en Norteamérica}
\label{tab:emna}

\setlength{\tabcolsep}{1pt}% just a minimum
\begin{tabular*}{\linewidth}{
  @{\extracolsep{\fill}}
  l
  S[table-format=7.0]
  c
  S[table-format=7.0]
  c
  S[table-format=5.0]
  c
  S[table-format=5.1]
  c
  @{}
}
\toprule
País & {Producción} & Fecha
     & {Consumo} & Fecha
     & {Exportaciones} & Fecha
     & {Importaciones} & Fecha \\
     & {(\si{\giga\watt\hour})} &
     & {(\si{\giga\watt\hour})} &
     & {(\si{\giga\watt\hour})} &
     & {(\si{\giga\watt\hour})} & \\
\midrule
Canadá  &  612000 & 2007 &  530000 & 2006 & 50120 & 2007 & 19660   & 2007 \\
EUA     & 4167000 & 2007 & 3892000 & 2007 & 20140 & 2007 & 51400   & 2007 \\
México  &  243300 & 2007 &  202000 & 2007 &  1278 & 2007 &   482.2 & 2007 \\ 
\bottomrule         
\end{tabular*}
\end{table}   
\end{document}

여기에 이미지 설명을 입력하세요

답변3

이 코드는 작동합니다. 나는 당신의 테이블을 개선할 기회를 잡았습니다. 당신에게는 tabularx환경이 정말로 필요하지 않다고 생각하므로 Y열을 일반 l. 또한 필요하다고 생각되면 패키지를 사용하여 열 머리글을 두 줄로 만들었습니다 makecell.

\documentclass[fontsize=10pt, paper=letter, headings=small, bibliography=totoc, DIV=9, headsepline=true, titlepage=on]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[spanish,mexico]{babel}
\usepackage{xspace}
\usepackage{xkeyval}
\usepackage{array,multirow,multicol,rotating,tabularx,ragged2e,booktabs}
\usepackage{ makecell}

\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}[htb]
  \centering
  \caption{Reservas y Recursos Prospectivos}
  \label{tab:RecOtorgados}%{0.85\linewidth}
  \begin{tabular}{@{}l@{\qquad}S[table-format=5.0]S[table-format=5.0] @{}}%
    \toprule
    Tipo/Área & {\thead{Recursos 2P \\{} [MMBPCE]}} & {\thead{Recursos Prospectivo\\{} [MMBPCE]}} \\
    \midrule
    Convencional & 20589 & 18222 \\
    Aguas Someras & 11374 & 7472 \\
    Sureste & 11238 & 7472 \\
    Norte & 136 & \\
    Terrestre & 8818 & 5913 \\
    Sur & 4379 & 5371 \\
    Chicontepec & 3556 & \\
    Burgos & 425 & \\
    Resto Norte & 459 & 542 \\
    Aguas Profundas & 397 & 4837 \\
    Perdido & & 3013 \\
    Holok-Han & 397 & 1824 \\
    No Convencional & & 5225 \\
    \midrule
    Total & 20589 & 23447 \\
    \bottomrule
  \end{tabular}
\end{table}
\end{document} 

여기에 이미지 설명을 입력하세요

답변4

먼저 귀하의 질문에 답변하기 위해(오류 수정): 열에 숫자가 아닌 셀을 사용했습니다 S. "e"로 읽거나 "e"로 시작해야 합니다. 이 셀을 중괄호 안에 넣으세요.

이제 일반적으로 테이블에 대해 tabularx숫자 데이터와 함께 사용하지 마십시오. 테이블이 에 비해 너무 크므로 \linewidth수동으로 너비를 줄이세요.

이는 다음과 같습니다:

% arara: pdflatex

\documentclass[fontsize=10pt,paper=letter,headings=small,DIV=9,headsepline=true]{scrartcl}     
\usepackage[spanish,mexico]{babel}  
\usepackage[utf8]{inputenc}
\usepackage{booktabs} 
\usepackage{caption}
%\usepackage{rotating} % do not load that twice
\usepackage{siunitx}
\sisetup{group-minimum-digits = 4}

\begin{document}    
    \begin{table}[htbp]
        \centering
        \tabcolsep=1.33ex
        \caption{Mercado de energía eléctrica en Norteamérica}
        \label{tab:emna}
        \begin{tabular}{@{}lS[table-format=7.0]cS[table-format=7.0]cS[table-format=5.0]cS[table-format=5.1]c@{}}
            \toprule
            País & {Producción} & Fecha & {Consumo}  & Fecha & {Exptciones} & Fecha & {Imptciones} & Fecha \\
            & {en \si{\giga\watt\hour}} & & {en \si{\giga\watt\hour}} & & {en \si{\giga\watt\hour}} & & {en \si{\giga\watt\hour}} & \\
            \midrule
            Canadá &  612000 & 2007 &  530000 & 2006 & 50120 & 2007 & 19660   & 2007 \\
            EEUU   & 4167000 & 2007 & 3892000 & 2007 & 20140 & 2007 & 51400   & 2007 \\
            México &  243300 & 2007 &  202000 & 2007 &  1278 & 2007 &   482.2 & 2007 \\ 
            \bottomrule         
        \end{tabular}
    \end{table}   
\end{document}

정말로 사용하고 싶다면 tabularx여기에서 답변을 찾을 수 있습니다.siunitx와 tabularx를 함께 사용하는 방법은 무엇입니까?

여기에 이미지 설명을 입력하세요

장치 주위에 브래킷을 사용하지 마십시오. 그것은 잘못된 것입니다.

관련 정보