# csv to latex chart

What I want: to make a chart from a csv file (exp1.csv).

Problem:

1. I don't get all the data visible in the chart
2. The header of my table is not consistent (see \hline) Could you help me to solve those two problems?
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[left=3cm,top=3cm,right=3cm]{geometry}
\usepackage{tabularx}
\usepackage{xfrac}
\usepackage{float}
\newcolumntype{Y}{>{\small\raggedright\arraybackslash}X}
\usepackage{csvsimple}

\begin{filecontents*}{exp1.csv}
Ultrapure,0.406,0.384,0.362
Deionized,2.78,2.769,2.603
\end{filecontents*}

\begin{document}

\subsection*{Characterisation of chemicals}
\begin{table}[ht]{
\scalebox{1}{
\begin{tabularx}{\textwidth}{|Y||Y|Y|}
\bfseries Water type & \bfseries value 1 & \bfseries value 2\\
{\\\hline\csvcoli&\csvcolii& \csvcoliii}\\
\hline
\end{tabularx}}}
\end{table}

\end{document}


• Your csv file has four columns, hence I guess your tabular also need four columns.
• Your csv contains no table head, hence the use of option no head.
\documentclass[a4paper, 11pt]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[left=3cm,top=3cm,right=3cm]{geometry}
\usepackage{tabularx}
\usepackage{xfrac}
\usepackage{float}
\newcolumntype{Y}{>{\small\raggedright\arraybackslash}X}
\usepackage{csvsimple}

\begin{filecontents*}{exp1.csv}
Ultrapure,0.406,0.384,0.362
Deionized,2.78,2.769,2.603
\end{filecontents*}

\begin{document}

\subsection*{Characterisation of chemicals}
\begin{table}[ht]
\begin{tabularx}{\textwidth}{*3{|Y}|Y|}
\hline
\bfseries Water type & \bfseries value 1 & \bfseries value 2 & \bfseries value 3
\\ \hline
\end{tabularx}
\end{table}

\end{document}


### Follow-up: Multi-page tables with X column type

• Load ltablex and uses \keepXColumns to activate the effect of X column type.
• Move tabularx environment output of table floating environment, and use tabularx like longtable environment. For example, use \caption{...} \\ in tabularx to put an caption.
\documentclass[a4paper, 11pt]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[left=3cm,top=3cm,right=3cm]{geometry}
\usepackage{tabularx}
\usepackage{ltablex}
\keepXColumns

\usepackage{xfrac}
\usepackage{float}
\newcolumntype{Y}{>{\small\raggedright\arraybackslash}X}

\usepackage{csvsimple}

\begin{filecontents*}{exp1.csv}
Ultrapure,0.406,0.384,0.362
Deionized,2.78,2.769,2.603
\end{filecontents*}

\begin{document}

\subsection*{Characterisation of chemicals}
\begin{tabularx}{\textwidth}{XXXX}
\caption{text} \\
\hline
\bfseries Water type & \bfseries value 1 & \bfseries value 2 & \bfseries value 3

• @Elia: xltabular combines the features of tabularx (X type columns) and longtable(mid-table page breaks). Why would you need tabularx in the first place for this specific table? The only thing it does here is artificially making the table a lot wider than it needs to be, making it less readable. – leandriis May 22 '20 at 6:53
• @Elia I've appended a multi-page table with X column type to my answer. – muzimuzhi Z May 22 '20 at 6:56