1

I cannot figure out how to modify the Code given in this post in order to create an horizontal line over the last entry of the last column. That means I want the table to look like this (please excuse my bad drawing ;)):

enter image description here

Thank you

1
  • While it might be possible to hack something in that direction, I am not sure whether CSV is actually the right tool to accomplish this. CSV has merely a definition of a "header" row. Maybe using one of the tabular* packages is the easier way to go here.
    – languitar
    Commented Sep 15, 2016 at 11:03

1 Answer 1

1

You could do something like

late after line=\ifnumequal{\thecsvrow}{3}{\\\midrule}{\\},

too add a rule at a certain line.

The full source code is:

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

enter image description here

Update:

To use a dashed line, the arydshln package may be used which provides \hdashline. I have no experience with that package, but the following seems to work:

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

This gives: enter image description here

2
  • Excellent. Thank you very much. Do you maybe even know if there is a way to make this new line appear in a dashed style?
    – s88_py
    Commented Sep 16, 2016 at 11:35
  • @s88_py I updated my answer with some code for a dashed style. Commented Sep 20, 2016 at 8:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .