答案1
你可以做类似的事情
late after line=\ifnumequal{\thecsvrow}{3}{\\\midrule}{\\},
在某一行添加一条规则。
完整源代码为:
\documentclass{article}
\usepackage{csvsimple,booktabs}
% csv file
\begin{filecontents*}{grade.csv}
name,givenname,matriculation,gender,grade
Maier,Hans,12345,m,1.0
Huber,Anna,23456,f,2.3
Weisbaeck,Werner,34567,m,5.0
\end{filecontents*}
\begin{document}
\csvreader[
tabular=ccccc,
table head=\toprule name & givenname & matriculation & gender & grade\\\midrule,
late after line=\ifnumequal{\thecsvrow}{3}{\\\midrule}{\\},
late after last line=\\,
table foot=\bottomrule,
head to column names,
]
{grade.csv}{}
{\name & \givenname & \matriculation & \gender & \grade}
\end{document}
更新:
要使用虚线,arydshln
可以使用提供 的包\hdashline
。我没有使用该包的经验,但以下方法似乎有效:
\documentclass{article}
\usepackage{csvsimple,booktabs,arydshln}
% csv file
\begin{filecontents*}{grade.csv}
name,givenname,matriculation,gender,grade
Maier,Hans,12345,m,1.0
Huber,Anna,23456,f,2.3
Weisbaeck,Werner,34567,m,5.0
\end{filecontents*}
\begin{document}
\csvreader[
tabular=ccccc,
table head=\toprule name & givenname & matriculation & gender & grade\\\midrule,
late after line=\ifnumequal{\thecsvrow}{3}{\\\hdashline}{\\},
late after last line=\\,
table foot=\bottomrule,
head to column names,
]
{grade.csv}{}
{\name & \givenname & \matriculation & \gender & \grade}
\end{document}