0

I am trying to fit a table into textwidth using pgfplotstable. The code I found in this forum (here) somehow produces red lines and I do not know why this is the case. enter image description here

This is how the results looks like. I do not understand what happens top/left. Also do you happen to know how to left-align the columns? Result

The biggest difference between my code and the code I found is that I am storing my data in a csv file. Any suggestions and solutions are highly appreciated. This is my code:

\usepackage{float}
\usepackage{pgfplotstable,tabularx,booktabs}
\pgfplotsset{compat=1.17}

\begin{document}

\begin{table} \centering \caption{\textbf{Caption} } \label{caption} \footnotesize
\pgfplotstabletypeset[ column type=, begin table={\begin{tabularx}{\textwidth}{X c c c c}}, end table={\end{tabularx}}, multicolumn names, % allows to have multicolumn names col sep=comma, column type={l}, % the separator in the .csv file + column raggedleft display columns/0/.style={ column name=$ $, %first column because it is string type column type={l},string type}, every head row/.style={ before row= \toprule,% have a rule at top after row={ \si{\ampere} & \si{\volt}\ % the units separated by & \midrule} % rule under units }, every last row/.style={after row=\bottomrule}, % rule at bottom ]{Datafile.csv} % filename/path to file \raggedright \newline \footnotesize{\textit{Sources}} \end{table}

\end{document}

Leslie
  • 21
  • Your code is missing \documentclass. It also looks like you want to add \usepackage{situnitx}. Please include the csv file as well – mbert Nov 09 '22 at 17:25
  • The red lines are from your editor telling you there's an error at that point in the code (hence the ⌧ on the left). I wouldn't read too much into the exact location of the highlighting. The log file will be more informative as to the actual error – mbert Nov 09 '22 at 17:28

0 Answers0