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

  • 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 Sep 15 '16 at 11:03
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

  • 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 Sep 16 '16 at 11:35
  • @s88_py I updated my answer with some code for a dashed style. – Thomas F. Sturm Sep 20 '16 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.