pgfplotstable - siunitx 错误,数据来自 csv,值采用科学计数法

pgfplotstable - siunitx 错误,数据来自 csv,值采用科学计数法

我想使用 pgfplotstable 和来自 csv 文件的数据创建表格,其中的值采用科学计数法,但当我尝试将文件编译为 pdf 时,最终出现以下 siunitx 错误

Package siunitx: Invalid numerical input '8.47e'.
Package siunitx: Invalid numerical input '2e'.
Package siunitx: Invalid numerical input '1.9e'.
Package siunitx: Invalid numerical input '2e'.
and so on...

这是我的代码

    \begin{table}[h!]
        \begin{center}
            \pgfplotstabletypeset[
                col sep=comma,
                header=false,
                display columns/0/.style={
                    column name=$U_{led}$,
                    column type={S},
                    string type
                },
                display columns/1/.style={
                    column name=$I_{led}$,
                    column type={S},
                    string type
                },
                display columns/2/.style={
                    column name=$U_{det}$,
                    column type={S},
                    string type
                },
                every head row/.style={
                    before row={\toprule},
                    after row={{[\si{\volt}]} & {[\si{\milli\ampere}]} & {[\si{\volt}]}\\\midrule}
                },
                every last row/.style={after row=\bottomrule},
            ]{../data/va_lux_char.csv}
            \label{table:va_lux}
            \caption{Tabulka}
        \end{center}
    \end{table}

这是我的 CSV 文件

0.646,8.47e-08,2e-06
1.11,1.9e-07,2e-06
1.288,2.96e-07,2e-06
1.388,6.97e-07,2e-06
1.413,9.93e-07,2e-06
1.456,1.99e-06,2e-06
1.479,3e-06,2e-06
1.526,6.99e-06,2e-06
1.545,9.99e-06,2e-06
1.581,2e-05,0.000124
1.602,3e-05,0.000384
1.644,7e-05,0.00231
1.698,0.0002,0.0141
1.718,0.0003,0.0249
1.765,0.0007,0.0639
1.788,0.001,0.0858
1.838,0.002,0.131
1.875,0.003,0.159
1.978,0.007,0.218
2.037,0.01,0.242
2.205,0.02,0.288
2.35,0.03,0.315
2.443,0.037,0.329

编辑: 我发现问题出在 siunitx 和使用-活动字符的 czech babel packege 的组合上,因此使用表格\shorthandoff{-}上方和\shorthandon{-}下方的符号解决了这个问题,现在它运行良好。

答案1

在此处输入图片描述

 \documentclass[10pt,a4paper]{article}

\usepackage{graphicx, pgfplots,array,booktabs,siunitx,}
\usepackage{pgfplotstable,filecontents}

\begin{filecontents}{data1.csv}
    0.646,8.47e-08,2e-06
    1.11,1.9e-07,2e-06
    1.288,2.96e-07,2e-06
    1.388,6.97e-07,2e-06
    1.413,9.93e-07,2e-06
    1.456,1.99e-06,2e-06
    1.479,3e-06,2e-06
    1.526,6.99e-06,2e-06
    1.545,9.99e-06,2e-06
    1.581,2e-05,0.000124
    1.602,3e-05,0.000384
    1.644,7e-05,0.00231
    1.698,0.0002,0.0141
    1.718,0.0003,0.0249
    1.765,0.0007,0.0639
    1.788,0.001,0.0858
    1.838,0.002,0.131
    1.875,0.003,0.159
    1.978,0.007,0.218
    2.037,0.01,0.242
    2.205,0.02,0.288
    2.35,0.03,0.315
    2.443,0.037,0.329
\end{filecontents}

\begin{document}
     \begin{table}[h!]
        \begin{center}
            \pgfplotstabletypeset[
            col sep=comma,
            header=false,
            display columns/0/.style={
                column name=$U_{led}$,
                column type={S},
                string type
            },
            display columns/1/.style={
                column name=$I_{led}$,
                column type={S},
                string type
            },
            display columns/2/.style={
                column name=$U_{det}$,
                column type={S},
                string type
            },
            every head row/.style={
                before row={\toprule},
                after row={{[\si{\volt}]} & {[\si{\milli\ampere}]} & {[\si{\volt}]}\\\midrule}
            },
            every last row/.style={after row=\bottomrule},
            ]{data1.csv}
            \label{table:va_lux}
            \caption{Tabulka}
        \end{center}
    \end{table}
\end{document}

相关内容