1

I am trying to include a table caption above the table, but the closest I've come is printing the caption between the table header and the first row (as per the code below). Any other place I've placed the caption in the \pgfplotstabletypeset[ results in an error. Code:

%----- TEX FILE TO FORMAT DOCUMENT REVISION HISTORY TABLE ----
%           DATE: 2-MAY-2018
%           AUTHOR: Fred Tamm-Daniels
%
\documentclass{article}
\usepackage[english]{babel}

%------ COMMENTS
\usepackage{comment}
                                                                                                                                                                                                                                                                                                                                                                                                                          %----- GRAPHICS STUFF
\usepackage{graphicx} % Allows the importing of images
\usepackage{float} % Allows for control of float positions

%----- TABLE OF CONTENTS
\usepackage{titletoc}
\usepackage[hidelinks]{hyperref} % Allows clickable references

%----- TABLE OF FIGURES & TABLES & CAPTIONS
\usepackage{tocloft}
\usepackage{caption}

%----- ENABLE IMPORT OF PDF DOCUMENTS
\usepackage{pdfpages}

%----- ENABLE LANDSCAPE MODE
\usepackage{pdflscape}

%----- MODIFY PARAGRAPH SETTING
\usepackage{titlesec}
\titleformat{\paragraph}
{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}
{0pt}{1.5ex plus 1ex minus .2ex}{1.5ex plus .2ex}

%----- FORMAT QUOTATION MARKS
%\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{upquote}
\usepackage{listings}
%\lstset{upquote=true}

%----- INCREASE SECTION NUMBERING TO 4 LEVELS
\setcounter{secnumdepth}{4}

%----- ENABLE HYPERLINKS
\usepackage{hyperref}

%----- ENABLE MODIFICATION OF QUOTE INDENTATION
\usepackage{changepage}
\usepackage{parskip}
\setlength{\parskip}{\baselineskip}%
\setlength{\parindent}{0pt}%

%----- IMPORT DATA
\usepackage{enumitem}
\usepackage{datatool,filecontents}
\DTLsetseparator{ = } %---SET SEPARATOR BETWEEN THE COLUMNS INCL WHITESPACE

%------ FORMATTING
\usepackage[letterpaper, margin=1in,headheight=25pt,footskip=40pt]{geometry}
\usepackage{parskip}
\usepackage{fancyhdr}
\usepackage{ragged2e}

%------ PACKAGES NEEDED FOR TABLES
\usepackage{booktabs}
\usepackage{pgfplotstable,pgfplots}
\usepackage{longtable}
\usepackage{hhline}
\usepackage{varwidth}
\pgfplotsset{compat=1.14}

%------ SET FONT TO ARIAL LOOK-ALIKE
\renewcommand{\rmdefault}{phv} % Arial
\renewcommand{\sfdefault}{phv} % Arial

%------ OVERRIDE DEFAULT PAGE STYLE
\pagestyle{fancy}
\fancyhf{}

\begin{filecontents*}{Test_Num_Steps.csv}
Test ID,Test Title,Num of Steps,Comments
4.1,Security and Privacy Test,13,
4.2,Navigation Test,58,In Internet Explorer 10 the search box in the directory structure does not highlight matching elements.(ABITT-949)
4.3,Sequence Display (MSC Display Mode) Test,58,
4.4,User Interface Script Editor Test,16,
4.5,Message Filtering Test,32,
4.6,Server Hardware Configuration Test,12,
4.7,Server Software Configuration Test,12,
4.8,Script Interface Test,40,
4.9,Header Configuration Test,83,
4.10,Traffic Generation/Export/Import Test,48,
4.11,Data Extraction Tool Test,36,
4.12,Event Injection Test,7,
4.13,Library Support Test,12,
4.14,System Version Integrity Check Test,21,
4.15,File Selection Test,11,
4.16,Command Line Interface (CLI) Test,11,
4.17,Server Load Test,18,
4.18,Dynamic Topic Test,11,
4.19,Replay Tool Test,15,
4.20,Multiple A-Side Test,13,History setting is causing the second side issues
4.21,Multiple Participant Test,10,
4.22,Error Reporting Test,20,This test needs revision so that core code does not have to be modified.
4.23,Multiple Standards Test,4,
4.24,Messaging Validation Test,40,
4.25,Connection Sequence Test,27,
4.26,Script Stress Test,8,
4.27,DHCP Test,15,
4.28,External NTP Source Test,14,
4.29,Internal NTP Source Test,13,
4.30,Data Load Interrupt Test,19,
4.31,Virus Definition Update Instructions Verification,3,
4.32,DVD-ROM Software Installation Verification,1,
4.33,Packaging and Labeling Verification ,1,
\end{filecontents*}

\begin{document}

\pgfplotsset{compat=1.14}
\showboxbreadth=5
\centering
\pgfplotstableread[col sep=comma]{Test_Num_Steps.csv}\data

\def\arraystretch{1.5}%   
\headheight=39pt
 \pgfplotstabletypeset[
        string type,
        every head row/.style={before row={\hhline{|-|-|-|-|}},
                                            after row={\hhline{|-|-|-|-|}\midrule[\heavyrulewidth]}},
            begin table=\begin{longtable},
            every first row/.append style={before row={%
            \hhline{|-|-|-|-|}%
        \caption{Test Metrics Summary}
            \endfirsthead%
        \hhline{|-|-|-|-|}
                Test ID & Test Title & Num of Steps & Comments \\ \hhline{|-|-|-|-|}
            \midrule[\heavyrulewidth]
            \hhline{|-|-|-|-|}
            \endhead
                \hline \multicolumn{4}{|r|}{{Continued on next page}} \\ \hline
            \endfoot
%                   \bottomrule
                \endlastfoot
        }},%
        end table=\end{longtable},
        %
        display columns/0/.style={column type={|c|}},
        display columns/1/.style={column type={p{.4\textwidth}|}},
        display columns/2/.style={column type={c|}},
        display columns/3/.style={column type={p{.3\textwidth}|}},
        every nth row={1}{before row=\hhline{|-|-|-|-|},
                                    after row=\hhline{|-|-|-|-|}},
]{\data}
\justifying

\end{document}
2

You have to place the caption before the first row as follows,

%----- TEX FILE TO FORMAT DOCUMENT REVISION HISTORY TABLE ----
%           DATE: 2-MAY-2018
%           AUTHOR: Fred Tamm-Daniels
%
\documentclass{article}
\usepackage[english]{babel}

%------ COMMENTS
\usepackage{comment}
                                                                                                                                                                                                                                                                                                                                                                                                                            %----- GRAPHICS STUFF
\usepackage{graphicx} % Allows the importing of images
\usepackage{float} % Allows for control of float positions

%----- TABLE OF CONTENTS
\usepackage{titletoc}
\usepackage[hidelinks]{hyperref} % Allows clickable references

%----- TABLE OF FIGURES & TABLES & CAPTIONS
\usepackage{tocloft}
\usepackage{caption}

%----- ENABLE IMPORT OF PDF DOCUMENTS
\usepackage{pdfpages}

%----- ENABLE LANDSCAPE MODE
\usepackage{pdflscape}

%----- MODIFY PARAGRAPH SETTING
\usepackage{titlesec}
\titleformat{\paragraph}
{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}
{0pt}{1.5ex plus 1ex minus .2ex}{1.5ex plus .2ex}

%----- FORMAT QUOTATION MARKS
%\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{upquote}
\usepackage{listings}
%\lstset{upquote=true}

%----- INCREASE SECTION NUMBERING TO 4 LEVELS
\setcounter{secnumdepth}{4}

%----- ENABLE HYPERLINKS
\usepackage{hyperref}

%----- ENABLE MODIFICATION OF QUOTE INDENTATION
\usepackage{changepage}
\usepackage{parskip}
\setlength{\parskip}{\baselineskip}%
\setlength{\parindent}{0pt}%

%----- IMPORT DATA
\usepackage{enumitem}
\usepackage{datatool,filecontents}
\DTLsetseparator{ = } %---SET SEPARATOR BETWEEN THE COLUMNS INCL WHITESPACE

%------ FORMATTING
\usepackage[letterpaper, margin=1in,headheight=25pt,footskip=40pt]{geometry}
\usepackage{parskip}
\usepackage{fancyhdr}
\usepackage{ragged2e}

%------ PACKAGES NEEDED FOR TABLES
\usepackage{booktabs}
\usepackage{pgfplotstable,pgfplots}
\usepackage{longtable}
\usepackage{hhline}
\usepackage{varwidth}
\pgfplotsset{compat=1.14}

%------ SET FONT TO ARIAL LOOK-ALIKE
\renewcommand{\rmdefault}{phv} % Arial
\renewcommand{\sfdefault}{phv} % Arial

%------ OVERRIDE DEFAULT PAGE STYLE
\pagestyle{fancy}
\fancyhf{}

\begin{filecontents*}{Test_Num_Steps.csv}
Test ID,Test Title,Num of Steps,Comments
4.1,Security and Privacy Test,13,
4.2,Navigation Test,58,In Internet Explorer 10 the search box in the directory structure does not highlight matching elements.(ABITT-949)
4.3,Sequence Display (MSC Display Mode) Test,58,
4.4,User Interface Script Editor Test,16,
4.5,Message Filtering Test,32,
4.6,Server Hardware Configuration Test,12,
4.7,Server Software Configuration Test,12,
4.8,Script Interface Test,40,
4.9,Header Configuration Test,83,
4.10,Traffic Generation/Export/Import Test,48,
4.11,Data Extraction Tool Test,36,
4.12,Event Injection Test,7,
4.13,Library Support Test,12,
4.14,System Version Integrity Check Test,21,
4.15,File Selection Test,11,
4.16,Command Line Interface (CLI) Test,11,
4.17,Server Load Test,18,
4.18,Dynamic Topic Test,11,
4.19,Replay Tool Test,15,
4.20,Multiple A-Side Test,13,History setting is causing the second side issues
4.21,Multiple Participant Test,10,
4.22,Error Reporting Test,20,This test needs revision so that core code does not have to be modified.
4.23,Multiple Standards Test,4,
4.24,Messaging Validation Test,40,
4.25,Connection Sequence Test,27,
4.26,Script Stress Test,8,
4.27,DHCP Test,15,
4.28,External NTP Source Test,14,
4.29,Internal NTP Source Test,13,
4.30,Data Load Interrupt Test,19,
4.31,Virus Definition Update Instructions Verification,3,
4.32,DVD-ROM Software Installation Verification,1,
4.33,Packaging and Labeling Verification ,1,
\end{filecontents*}

\begin{document}
\pgfplotsset{compat=1.14}
\showboxbreadth=5
\centering
\pgfplotstableread[col sep=comma]{Test_Num_Steps.csv}\data

\def\arraystretch{1.5}%
\headheight=39pt
 \pgfplotstabletypeset[
        string type,
        every head row/.style={before row={
        \caption{Test Metrics Summary} \\           
        \hhline{|-|-|-|-|}},
        after row={\hhline{|-|-|-|-|}\midrule[\heavyrulewidth]}},
            begin table=\begin{longtable},
            every first row/.append style={before row={%
            \hhline{|-|-|-|-|}%
            \endfirsthead%
        \hhline{|-|-|-|-|}
                Test ID & Test Title & Num of Steps & Comments \\ \hhline{|-|-|-|-|}
            \midrule[\heavyrulewidth]
            \hhline{|-|-|-|-|}
            \endhead
                \hline \multicolumn{4}{|r|}{{Continued on next page}} \\ \hline
            \endfoot
%                   \bottomrule
                \endlastfoot
        }},%
        end table=\end{longtable},
        %
        display columns/0/.style={column type={|c|}},
        display columns/1/.style={column type={p{.4\textwidth}|}},
        display columns/2/.style={column type={c|}},
        display columns/3/.style={column type={p{.3\textwidth}|}},
        every nth row={1}{before row=\hhline{|-|-|-|-|},
                                    after row=\hhline{|-|-|-|-|}},
]{\data}
\justifying
\end{document}

Hope that helps.

Romain

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.