0

I have successful managed (with help from this forum) to display my options in a table with each line numbered and price displayed.

\csvreader[longtable= >{\stepcounter{RowNum}\theRowNum}r 
>{\everypar{\hangindent0.7cm}}p{13cm} b{1.3cm},  filter ifthen=\equal{\csvcolii}{1}  
%,  \multicolumn{3}{r}{{{\scriptsize \textit{ Continued on next page}}}} \\ \endfoot 
]{\excel}{17=\dbo, 18=\deo, 15=\pricel,16=\pricer} 
{& \textbf{\dbo} \deo & \mce  \\ \mce  && \$  \hfill \ifthenelse{\equal{\pricel}{0}} 
{}{\pricel,}\pricer \\ \mce \\ \mce}

It also goes over the page, when I start the table at the bottom of the page.

Two things I would like to add:

  1. Price should always stay together with option.
  2. On bottom of page it should read: 'Continued on next page', but I'm not sure where to add the \endfoot comment which I found as solution to my request.

Here a MWE which runs, goes over 1 page and the price is split:

\documentclass[a4paper,12p]{article}

\usepackage{longtable} % allows list to split over the page
\usepackage{pgfplotstable} % for "continued on next page"

\usepackage{tabularx} % for the table format
\newcommand\mce{\multicolumn{1}{c}{}}
\newcounter{RowNum}
\usepackage{siunitx} %counting row numbers

\usepackage{csvsimple} % read Excel tables

\begin{filecontents*}{excel.csv}
included,optioned,dbo,deo,pricel, pricer
0,1,D, d, 12,299
1,0,E,e,0,99
0,1,E,e,0,99
0,1,A, d, 14,299
0,1,D, d, 12,299
1,0,E,e,0,99
0,1,E,e,0,99
0,1,A, d, 14,299
0,1,D, d, 12,299
1,0,E,e,0,99
0,1,E,e,0,99
0,1,A, d, 14,299
0,1,D, d, 12,299
1,0,E,e,0,99
0,1,E,e,0,99
0,1,A, d, 14,299
0,1,D, ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd, 12,299
1,0,E,e,0,99
0,1,E,e,0,99
0,1,A, d, 14,299
\end{filecontents*}

\begin{document}
\setlength{\parindent}{0pt} % never indent first line


\csvreader[longtable= >{\stepcounter{RowNum}\theRowNum}r >{\everypar{\hangindent0.7cm}}p{3cm} b{1.3cm}, filter ifthen=\equal{\csvcolii}{1} %,  \multicolumn{3}{r}{{{\scriptsize \textit{ Continued on next page}}}} \\ \endfoot
]{excel.csv}{3=\dbo, 4=\deo, 5=\pricel,6=\pricer}{& \textbf{\dbo} \deo & \mce  \\ \mce   && \$  \hfill \ifthenelse{\equal{\pricel}{0}}{}{\pricel,}\pricer \\ \mce \\ \mce}

\end{document}
3
  • What does "Price should always stay together with option" mean specifically? – leandriis Jan 7 at 10:48
  • In my MWE it shows that the option 13 has description on page1, but price is listed on page2. I would like to have description and price on one page. – Chris Peh Jan 8 at 0:48
  • I have edited my answer to also account for that. – leandriis Jan 8 at 18:15
1

Partial answer to help fulfill request 2:

You can use the table head key:

\csvreader[longtable= >{\stepcounter{RowNum}\theRowNum}r >{\everypar{\hangindent0.7cm}}p{3cm} b{1.3cm}, 
           filter ifthen=\equal{\csvcolii}{1} ,
           table head= \multicolumn{3}{r}{{{\scriptsize \textit{ Continued on next page}}}} \\ \endfoot \endlastfoot ,
]{excel.csv}{3=\dbo, 4=\deo, 5=\pricel,6=\pricer}{& \textbf{\dbo} \deo & \mce  \\ \mce   && \$  \hfill \ifthenelse{\equal{\pricel}{0}}{}{\pricel,}\pricer \\ \mce \\ \mce}

(I also added \endlastfoot in order to prevent "Continued on next page" to be shown on the last page of the table).


Update

The following code should also fulfill requirement 1. I used \\* instead of \\ to prevent pagebreaks:

\csvreader[longtable= >{\stepcounter{RowNum}\theRowNum}r p{3cm} b{1.3cm}, 
           filter ifthen=\equal{\csvcolii}{1} ,
           table head= \multicolumn{3}{r}{{{\scriptsize \textit{ Continued on next page}}}} \\ \endfoot \endlastfoot]
          {excel.csv}
          {3=\dbo, 4=\deo, 5=\pricel,6=\pricer}
          {       & \textbf{\dbo} \deo & \mce  \\* 
           \mce   &                    & \$  \hfill \ifthenelse{\equal{\pricel}{0}}{}{\pricel,}\pricer \\* 
           \mce \\ 
           \mce}
1
  • The above worked beautifully until now: Unfortunately the \handindent doesn't happen anymore which is confusing. What could have changed and how do I ensure that the second line is indented? – Chris Peh May 25 at 0:25

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.