Consider the following MWE which uses pgfplotstable and longtable to output some csv file content. The table counter are incrementet twice for each table added. Why?
\begin{filecontents*}{mytable.csv}
Chem.;Avg. Conc.;Avg. Conc. Norm.; Conc. Unit;Mass sum;Mass unit
ammonium;159083,33;114450,21;\si{\micro\gram\per\liter};2839,463;\si{\kilo\gram}
\end{filecontents*}
\documentclass{article}
\usepackage{booktabs, longtable, geometry}
\usepackage{siunitx}
\usepackage{pgfplotstable}
\pgfplotsset{compat=newest,}
\pgfplotstableset{
begin table=\begin{longtable},
end table=\end{longtable},
%every head row/.append style={before row=\captionof{table{Caption}}
}
\usepackage{capt-of}
\begin{document}
{\centering
\captionof{table}{First table}
\pgfplotstabletypeset[
header=has colnames,
col sep=semicolon,
read comma as period=true,
display columns/0/.style={column type={l},string type},
display columns/1/.style={sci,sci zerofill,sci sep align,},
display columns/2/.style={sci,sci zerofill,sci sep align,},
display columns/3/.style={column type={l},string type},
display columns/4/.style={sci,sci zerofill,sci sep align,},
display columns/5/.style={column type={l},string type},
]{mytable.csv}\par
}
{\centering
\captionof{table}{Second table}
\pgfplotstabletypeset[
header=has colnames,
col sep=semicolon,
read comma as period=true,
display columns/0/.style={column type={l},string type},
display columns/1/.style={sci,sci zerofill,sci sep align,},
display columns/2/.style={sci,sci zerofill,sci sep align,},
display columns/3/.style={column type={l},string type},
display columns/4/.style={sci,sci zerofill,sci sep align,},
display columns/5/.style={column type={l},string type},
]{mytable.csv}\par
}
{\centering
\captionof{table}{Third table}
\pgfplotstabletypeset[
header=has colnames,
col sep=semicolon,
read comma as period=true,
display columns/0/.style={column type={l},string type},
display columns/1/.style={sci,sci zerofill,sci sep align,},
display columns/2/.style={sci,sci zerofill,sci sep align,},
display columns/3/.style={column type={l},string type},
display columns/4/.style={sci,sci zerofill,sci sep align,},
display columns/5/.style={column type={l},string type},
]{mytable.csv}\par
}
\end{document}


tablebeing a box, I just addedtableto show that it happens there as well. Please see my edit. This happens also without thetableenvironment, replacingcaptionwith thecaptionofmacro. Am I positioning thecaption(of)wrong? – Holene Jan 28 '16 at 08:36\captionofthat increments the counter too, but in longtable, longtable itself increments the counter and\captiondoes not (so you can\captionrepeated for headings, etc) so if you are using longtable you need to use its caption (or just set the counter back by one). – David Carlisle Jan 28 '16 at 08:49