1

I want to shorten a tabular by making text in the first column consume more than one cell in the last (rather than first) rows of the tabular. I know csvsimple accepts macros however lines can't be started by a slash \, so I added a dot . to the beginning of the last line with the \multicolumn command.

However, that does not work. How could I accomplish this? Here's an example:

\documentclass{article}
\usepackage{csvsimple}
\usepackage{filecontents}

\begin{filecontents*}{data.csv}
a,b,c
d,e,f
g,h,i
.\multicolumn{2}{c}{j},,k
\end{filecontents*}

\begin{document}

\csvreader[
tabular = ccc,
late after line = \\,
head to column names,
no check column count,
respect none]
{data.csv}
{}
{\a & \b & \c}

\end{document}
  • 2
    once you start needing to put tex commands in the csv file isn't it simpler just to make the file a tabular and \input it rather than use a package to parse it? Basically you just need to use & instead of , and put \\ at the end of every line. – David Carlisle Dec 5 '19 at 21:02
  • you're right, that's certainly much simpler. I'm teaching a friend LaTeX and he got quite fascinated by the fact you can just import CSV files, so I wanted to see if he could keep working that way. – rberaldo Dec 5 '19 at 21:16

Your Answer

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

Browse other questions tagged or ask your own question.