csvreader 中的 longtable 错误

csvreader 中的 longtable 错误

通过导入 csv 文件创建 longtable 时出现错误。MWE 如下所示。

\begin{filecontents*}{monodisperse15.csv}
    20,2.825,5.967,0.0,0.0,0.0,0.0
    22,2.85,15.516,0.0,0.0,0.0,0.0
    24,3.126,11.748,0.0,0.0,0.0,0.0
    26,3.45,3.772,0.0,0.0,0.0,0.0
    28,3.544,8.243,0.0,0.0,0.0,0.0
    30,3.602,24.218,0.073,0.452,41.349,0.303
    32,3.59,31.384,0.08,1.466,36.664,0.113
    34,3.698,31.607,0.068,2.326,31.855,0.085
    36,3.807,31.383,0.079,2.831,31.416,0.071
    38,3.84,31.855,0.072,3.065,31.847,0.08
    40,3.796,34.43,0.081,3.211,34.673,0.101
    42,3.928,32.639,0.091,3.442,32.666,0.088
    44,3.807,34.366,0.077,3.414,34.459,0.089
    46,3.95,32.57,0.068,3.599,32.629,0.066
    48,4.118,31.789,0.072,3.788,31.793,0.073
    50,4.017,32.87,0.081,3.702,32.993,0.071
    52,4.101,31.811,0.068,3.769,31.81,0.072
    54,3.85,34.796,0.072,3.5,35.102,0.073
    56,4.065,31.607,0.071,3.658,31.616,0.074
    58,3.992,31.638,0.083,3.482,31.666,0.085
    60,3.845,32.86,0.073,3.249,32.93,0.091
    62,3.831,31.93,0.058,3.075,32.014,0.08
    64,3.721,32.106,0.073,2.735,32.291,0.09
    66,3.521,32.979,0.087,2.189,33.846,0.088
    68,3.558,31.687,0.092,1.405,33.543,0.121
    70,3.775,0.039,0.039,0.491,0.117,0.117
    72,3.65,0.478,0.0,0.0,0.0,0.0
    74,3.407,7.113,0.0,0.0,0.0,0.0
    76,3.111,17.893,0.0,0.0,0.0,0.0
    78,3.04,7.148,0.0,0.0,0.0,0.0
    80,2.764,14.752,0.0,0.0,0.0,0.0
\end{filecontents*}
\documentclass{article}
\usepackage{csvsimple}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{longtable}
\begin{document}
    \csvreader[
            longtable = @{}ccccccc@{},
            table head = 
                \toprule \(\psi_a^{as}\) & \multicolumn{3}{c}{Total} & \multicolumn{3}{c}{Active} &\\
                \cmidrule(lr){2-4} \cmidrule(lr){5-7}
                & \(\lambda\) & \(\sigma_{\text{Tot}}\) & \(\sigma_{\text{i}}^{\text{max}}\) & \(\lambda\) & \(\sigma_{\text{Tot}}\) & \(\sigma_{\text{i}}^{\text{max}}\)\\
                \midrule
                \endhead
                \bottomhead
                \endfoot,
            no head,
            column count = 7,
            late after line = \\
        ]{monodisperse15.csv}
        {1=\one, 2=\two, 3=\three, 4=\four, 5=\five, 6=\six, 7=\seven}
        {\one & \two & \three & \four & \five & \six & \seven}
\end{document}

错误消息

任何帮助,将不胜感激。

谢谢

答案1

  1. 删除多余的&删除标题中的 {积极的}
  2. \bottomhead用。。。来代替\bottomrule
  3. late after line = \\这里没有必要

\begin{filecontents*}{monodisperse15.csv}
    20,2.825,5.967,0.0,0.0,0.0,0.0
    22,2.85,15.516,0.0,0.0,0.0,0.0
    24,3.126,11.748,0.0,0.0,0.0,0.0
    26,3.45,3.772,0.0,0.0,0.0,0.0
    28,3.544,8.243,0.0,0.0,0.0,0.0
    30,3.602,24.218,0.073,0.452,41.349,0.303
    32,3.59,31.384,0.08,1.466,36.664,0.113
    34,3.698,31.607,0.068,2.326,31.855,0.085
    36,3.807,31.383,0.079,2.831,31.416,0.071
    38,3.84,31.855,0.072,3.065,31.847,0.08
    40,3.796,34.43,0.081,3.211,34.673,0.101
    42,3.928,32.639,0.091,3.442,32.666,0.088
    44,3.807,34.366,0.077,3.414,34.459,0.089
    46,3.95,32.57,0.068,3.599,32.629,0.066
    48,4.118,31.789,0.072,3.788,31.793,0.073
    50,4.017,32.87,0.081,3.702,32.993,0.071
    52,4.101,31.811,0.068,3.769,31.81,0.072
    54,3.85,34.796,0.072,3.5,35.102,0.073
    56,4.065,31.607,0.071,3.658,31.616,0.074
    58,3.992,31.638,0.083,3.482,31.666,0.085
    60,3.845,32.86,0.073,3.249,32.93,0.091
    62,3.831,31.93,0.058,3.075,32.014,0.08
    64,3.721,32.106,0.073,2.735,32.291,0.09
    66,3.521,32.979,0.087,2.189,33.846,0.088
    68,3.558,31.687,0.092,1.405,33.543,0.121
    70,3.775,0.039,0.039,0.491,0.117,0.117
    72,3.65,0.478,0.0,0.0,0.0,0.0
    74,3.407,7.113,0.0,0.0,0.0,0.0
    76,3.111,17.893,0.0,0.0,0.0,0.0
    78,3.04,7.148,0.0,0.0,0.0,0.0
    80,2.764,14.752,0.0,0.0,0.0,0.0
\end{filecontents*}

\documentclass{article}
\usepackage{csvsimple}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{longtable}
\begin{document}
    \csvreader[
            longtable = @{}ccccccc@{},
            table head = \toprule 
            \(\psi_a^{as}\) & \multicolumn{3}{c}{Total} 
                       & \multicolumn{3}{c}{Active} \\ % <-----
             %
                \cmidrule(lr){2-4} \cmidrule(lr){5-7}
             %
                & \(\lambda\) & \(\sigma_{\text{Tot}}\)
                & \(\sigma_{\text{i}}^{\text{max}}\) & \(\lambda\) 
                & \(\sigma_{\text{Tot}}\) 
                & \(\sigma_{\text{i}}^{\text{max}}\) \\
                \midrule
                \endhead
                \bottomrule % <------
                \endfoot,
            no head,
            column count = 7,
            % late after line = \\ <---------
        ]{monodisperse15.csv}
        {1=\one, 2=\two, 3=\three, 4=\four, 5=\five, 6=\six, 7=\seven}
        {\one & \two & \three & \four & \five & \six & \seven}
\end{document}

相关内容