1

I am making a long table for a paper appendix that spans multiple pages. I would like there to be no lines marking each row, except to designate sections. The only way I have figured out how to do it is to put "\hline" in the csv. When I put it on the end of the text in the fourth column, sometimes it adds an extra cell or adds an extra row; when I put "\hline" in its own row, it adds the extra row. Is it possible to designate the placement of these section markers within the csv without adding the extra row?

If possible, I would appreciate an answer that works within pgfplotstable and the csv input/formatting code I already have, as several other packages and attempts did not ultimately work with my table's needs. I adapted some code from an answer here (pgfplotstable; longtable with caption and repeating header), and would like to continue using pgfplotstable if possible - but this is a learning experience for me and I appreciate any suggestions. Thanks!

\begin{filecontents*}{SE_example.csv}
\textbf{Section 1:},,,
Item 1 has a long description,2000-2010,Short description here,a 
Item 2 also has a long description,1999-2005,This is a longer description and I need to keep this description long so I can be sure that the table will wrap,b
Item 3 is short,1995-2006,This is some text.,c 
\hline ,,,
\textbf{Section 2:},,,
Item 4,1999-2005,This is some more text.,d
Item 5,1995-2006,Text here,e \\ \hline
\textbf{Section 3:},,,
Item 6,1990-1997,Text text text,f
Item 7,2000-2004,Text text text text text,g \\ \hline
\textbf{Section 4:},,,
Item 8,1990-1997,Text text text,h
Item 9,2000-2004,Text text text text text,i
\end{filecontents*}

\documentclass[12pt, english]{article} 
\usepackage[table]{xcolor}
\definecolor{lightgray}{gray}{0.9}
\usepackage{csvsimple}
\usepackage{longtable}
\usepackage{caption}
\usepackage{setspace}
\usepackage{booktabs}
\usepackage{pgfplotstable}
\usepackage[hmargin=2.54cm, vmargin=2.54cm]{geometry}

\begin{document} 

\pgfkeysifdefined{/pgfplots/table/output empty row/.@cmd}{
% upcoming releases offer this more convenient option:
\pgfplotstableset{
    empty header/.style={
      every head row/.style={output empty row},
        }
    }
}{
   % versions up to and including 1.5.1 need this:
%    \pgfplotstableset{
%        empty header/.style={
%            typeset cell/.append code={%
%                \ifnum\pgfplotstablerow=-1 %
%                    \pgfkeyssetvalue{/pgfplots/table/@cell content}{}%
%                \fi
%            }
%        }
%    }
}

\rowcolors{1}{}{lightgray}
\scriptsize
\pgfplotstabletypeset[
empty header,
header=false,
begin table=\begin{longtable},
every first row/.append style={before row={%
\caption{Description of Policies}%
\label{tab:policies}\\\toprule
\textbf{Policy} &\textbf{Years} &\textbf{Description} &\textbf{Sources} \\ \toprule    
\endfirsthead
%
\multicolumn{4}{l}%
{{\bfseries Description of Policies \thetable\ Continued from previous page}} \\
\toprule 
%
\textbf{Policy} &\textbf{Years} &\textbf{Description} &\textbf{Sources} \\ \toprule      
\endhead
%
\midrule \multicolumn{4}{r}{{Continued on next page}} \\ \bottomrule
\endfoot
%
\midrule
\multicolumn{4}{r}{{Concluded}} \\ \bottomrule
\endlastfoot
}},%
%
end table=\end{longtable},
col sep=comma,
string type,
column type=l,
columns/0/.style={column type=p{6cm}},
columns/1/.style={column type=p{1.3cm}},
columns/2/.style={column type=p{6cm}},
columns/3/.style={column type=p{1cm}},
]{SE_example.csv}
\end{document}

enter image description here

1 Answer 1

0

Insert \hline at the beginning of the line. Also you don't need to use \\.

\textbf{Section 1:},,,
Item 1 has a long description,2000-2010,Short description here,a
Item 2 also has a long description,1999-2005,This is a longer description and I need to keep this description long so I can be sure that the table will wrap,b
Item 3 is short,1995-2006,This is some text.,c
\hline\textbf{Section 2:},,,
Item 4,1999-2005,This is some more text.,d
Item 5,1995-2006,Text here,e
\hline\textbf{Section 3:},,,
Item 6,1990-1997,Text text text,f
Item 7,2000-2004,Text text text text text,g
\hline\textbf{Section 4:},,,
Item 8,1990-1997,Text text text,h
Item 9,2000-2004,Text text text text text,i

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .