I have been trying to fix the column width of my table so that the text would automatically get warped to the next line and not shoot outside the page.
After searching for a few days, being a total newbie to Latex, I came across the first answer for this question:
Automatic line breaks in csvautobooklongtable
Although it does solve the problem, I'm not able to get the separating lines to appear in the table. I tried using late after line=\\\hline
for example but it is not working. I'm kinda going crazy here. Here is my current code:
\usepackage{array,booktabs,longtable,csvsimple,tabularx}
\makeatletter
\csvset{
my column width/.style={after head=\csv@pretable\begin{longtable}{*{\csv@columncount}{p{#1}}}\csv@tablehead},
}
\makeatother
\begin{document}
\csvautobooklongtable[separator=comma, respect all,
my column width=3cm, ]{NewTextDocument.csv}
\end{document}
If there is an alternative using \csvreader
I'm also open to that. And just to be clear on that I did try this code also:
\csvreader[longtable=|c|c|c|l|,my column width=2cm,
no head, column count=4,
table head=\hline,
late after line=\\\hline,
late after last line=\\\hline]
{NewTextDocument.csv}{}
{\csvlinetotablerow}
But my last column has a lot of text and is shooting outside the page instead of extending the row for another line. The same happens if I use tabular
instead of longtable
in the same code.
PS: I am trying to avoid stuff like tabularx
as it didn't compile at all when I tried it using this code:
\begin{tabularx}{\linewidth}{llXX}\toprule
\csvreader[no head,late after line=\\\midrule,late after last line=\\\bottomrule]
{NewTextDocument.csv}
{\csvcoli & \csvcolii & \csvcoliii & \csvcoliv}
\end{tabularx}
NewTextDocument.csv
so we can reproduce your issue? EDIT: you can modify it, but please test the issue still appears.