# multicolumn not working with pgfplotstabletypeset and tabularx

I am trying to reproduce a table with multicolumns like this one:

I understand that I should use multicolumn and multirow for producing the desire effect. This is the code I made:

\documentclass[
english,
a4paper,
10pt,
openany
]{book}
\usepackage{textcomp}
\usepackage{titlesec} % customize title format
\usepackage[margin=1.2cm]{geometry} % customize global margings
\usepackage{caption} % customize figure captions
\usepackage{graphicx}% include graphics
\usepackage{fancyhdr} % customize header and footer
\usepackage[titles]{tocloft} % customize toc
\usepackage{pgfplotstable, tabularx, booktabs, multirow} % Generates table from .csv
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\usepackage{xcolor, colortbl} % use colors for tables
\usepackage{ifpdf} % customize PDF output
\ifpdf
\usepackage[pdftex,
pagebackref=true,
unicode
]{hyperref}
\fi

\begin{filecontents*}{matrix.csv}
Max Current supply,\multicolumn{2}{l}{2A}
\multirow{4}{*}{Enclosure},Material,Aluminium
,Dimensions, 300x200x87 mm
,Weight, 2.2 Kg
,External Protection, IP65
Temperature Range,\multicolumn{2}{l}{-20$^\circ$C / 50$^\circ$C}
\end{filecontents*}

\begin{document}

\pgfplotstableset{zerofill}
\pgfplotstabletypeset[
reset styles,
debug=true,
string type,
col sep=comma,
row sep=\\,
every first row/.style={
before row={
\vspace{0.2em} % first row space between rows
}
},
column type=,
begin table={
\begingroup\renewcommand{\arraystretch}{1.2}
\begin{tabularx}{\textwidth}{
>{\columncolor[gray]{.8}}l@{\hskip 1.4em}
>{\columncolor[gray]{.95}}X
>{\columncolor[gray]{.95}}X
}
},
end table={\end{tabularx}\endgroup},
every nth row={1}{ before row={\vspace{0.2em}} }, % set space between rows
every head row/.style={ output empty row },  % suppress printing head row (numbers)
]{matrix.csv}

\end{document}


Compile using the command:

latexmk -pdf -pdflatex="pdflatex --synctex=1 --file-line-error" -use-make myfile.tex


No output is produced and the error message says that the number of columns don't match:

...PGFPlots found that the number of columns is larger than the previously determined number of columns...


I know the problem is the use of multicolum because if I remove the multicolumn command (and add a new column at the end) it produces this output:

Could somebody englight me why is multicolumn not working with pgfplotstabletypeset? and if there is a solution to use multicolumn or other alternative to produce a table like the example.

• if you put \multicolumn in to your data file then you have more than anything not separated the data and presentation, then trying to separate the rest of the presentation aspects from the place that you are specifying \multicolumn vastly complicates the coding, for no clear benefit. – David Carlisle Feb 6 '18 at 9:12
• why are you using -shell-escape here (that should only be used with caution) – David Carlisle Feb 6 '18 at 9:14