0

I've searched and found similar issues, but nothing that really worked in my application. I'm attempting to generate a pricebook with images/specs in a caption of a long table. That's all working great, but I would also like to apply alternating colors. Works fine, unless I have a longtable that spills over into the next page. It does not seem to reset the row count number, so it just applies the next background color as though it were directly below the original table. It should be white for first rows after the header, but the second table has a gray background. Here is what should be a working example:

\documentclass{report}
\renewcommand{\arraystretch}{1.5}
\usepackage[table]{xcolor}
\usepackage[final]{pdfpages}
\usepackage{fancyhdr}
\usepackage[letterpaper, lmargin=.5in, rmargin=.5in, tmargin=1in, bmargin=1in]{geometry}
\usepackage{caption}
\usepackage{tocloft}
\usepackage[export]{adjustbox}
\usepackage{longtable}
\usepackage{helvet}
\usepackage{everypage}
\usepackage[space]{grffile}
\usepackage{enumitem}
\usepackage{textcomp}
\usepackage[none]{hyphenat}
\renewcommand{\familydefault}{\sfdefault}
\setcounter{tocdepth}{5}
\pagestyle{fancy}

\renewcommand\footrule{\begin{minipage}{1\textwidth}
\hrule width \hsize height 2pt \kern 1mm \hrule width \hsize
\end{minipage}\par}%

\lfoot{\today}
\rfoot{\thepage}
\cfoot{}
\rhead{}
\lhead{\leftmark}
\renewcommand {\headrulewidth}{0.4pt}
\renewcommand {\footrulewidth}{0.4pt}
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}}
\captionsetup{labelsep=space,singlelinecheck=off,labelformat=empty,labelfont=bf}
%
\makeatletter
\setlength{\@fptop}{0pt}
\makeatother
%

\newif\ifimportant\importanttrue

\AddEverypageHook{
\global\importanttrue
}

\definecolor{light-gray}{HTML}{E5E4E2}
\definecolor{light-cyan}{HTML}{FFFFFF}
\definecolor{Gray}{gray}{0.80}
\definecolor{LightGray}{gray}{0.95}

\usepackage{url}
\urlstyle{sf}
\usepackage{hyperref}
\hypersetup{colorlinks,allcolors=black}

\begin{document}

\includepdfset{pagecommand=\thispagestyle{fancy}}

\cleardoublepage\phantomsection
\addcontentsline{toc}{chapter}{Clearance}
\markboth{Clearance}{}

\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\rowcolors{1}{light-cyan}{light-gray}
\begin{longtable}{p{.625in}p{1.5in}p{3.75in}p{.875in}}
\caption{
\ifimportant
\begin{minipage}[l]{0.3\textwidth}
\protect\includegraphics[width=1.875in,height=1.875in,keepaspectratio,left]{example-image}
\newline
\newline
\end{minipage}
\begin{minipage}[r]{0.7\textwidth}
\hspace{\fill}
\end{minipage}
\global\importantfalse
\fi
\textbf{Faucets}
}
\phantomsection\addcontentsline{toc}{section}{Faucets}\\
\hline
\rowcolor{Gray}
Product\# & Model\# & Description & Price\\
\hline
\endfirsthead
\caption[]{
\begin{minipage}[l]{0.3\textwidth}
\protect\includegraphics[width=1.875in,height=2in,keepaspectratio,left]{example-image}
\newline
\newline
\end{minipage}
\begin{minipage}[r]{0.7\textwidth}
\hspace{\fill}
\end{minipage}
\textbf{Faucets}
}\\
\hline
\rowcolor{Gray}
Product\# & Model\# & Description & Price\\
\hline
\endhead
387961 &  & K10577-4-2BZ BANCROFT WS LAV FCT & \$613.15 ea\\\hline
279697 & 10577-4P-BN & K10577-4P-BN BANCRFT W/S FCT & \$659.70 ea\\\hline
97397 &  & K11395-S 42 TRANS GRAB BAR ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASD & \$114.95 ea\\\hline
387968 &  & K11414-2BZ BANCROFT ROBE HOOK & \$42.40 ea\\\hline
37042 & 11581-CP & K11581-CP LOURE 24 TOWEL BAR & \$152.05 ea\\\hline
37906 & 11585-CP & K11585-CP LOURE ROBE HOOK & \$133.05 ea\\\hline
353981 & 11881-S & K11881-S MARGAUX 12 GRAB BAR & \$202.05 ea\\\hline
275281 & 11892-S & K11892-S PURIST 18 GRAB BAR & \$183.50 ea\\\hline
252952 & 12150-G & K12150-G 18IN BRU CHR TWL BAR & \$81.40 ea\\\hline
57743 & 12172-BN & K12172-BN FAIRFAX W/ SPRAY & \$383.45 ea\\\hline
2175 & 12177-G & K12177-G FAIRFAX P/O KIT FCT & \$413.55 ea\\\hline
256039 & 12182-BRZ & K12182-BRZ FAIRFAX S/H LAV FCT & \$353.00 ea\\\hline
100380 & 12183-BRZ & K12183-BRZ FAIRFAX SINK FCT & \$542.05 ea\\\hline
138661 & 128-SN & K128-SN ANTIQUE RISER TUBE(PR) & \$496.85 ea\\\hline
324289 & 13132-4B-BN & K13132-4B-BN PINSTRIPE LAV FCT & \$1353.70 ea\\\hline
15233 & 13864-CP & K13864-CP C/BRS SINK STRAINER & \$141.30 ea\\\hline
122632 & 15182-F-G & K15182-F-G LEVER HNDL LAV FCT & \$207.80 ea\\\hline
11301 & 16010-2-CP & K16010-2-CP TRITON SQR HDLS & \$68.60 ea\\\hline
51577 & 16012-2-CP & K16012-2-CP TRITON STD HANDLES & \$127.40 ea\\\hline
284047 & 16012-4-CP & K16012-4-CP TRITON LVR HANDLE & \$120.60 ea\\\hline
80275 & 16140-BV & K16140-BV TOWEL RING & \$358.40 ea\\\hline
92315 & 16141-BV & K16141-BV TOILET TISSUE HOLDER & \$354.85 ea\\\hline
88279 & 16146-BV & K16146-BV ROBE HOOK & \$203.25 ea\\\hline
84369 & 16150-BV & K16150-BV 24IN TOWEL BAR & \$432.45 ea\\\hline
286726 & 16252-CP & K16252-CP MARGAUX 30 TWL BAR & \$190.60 ea\\\hline
89795 & 16256-BN & K16256-BN MARGAUX ROBE HK & \$123.95 ea\\\hline
255048 & 303-K-NA & K303-K-NA 3-HNDL VALVE SYSTEM & \$165.80 ea\\\hline
\end{longtable}
\end{document}
  • Well, if I compile your document on my machine, the first row on the second page is white, and that's what you seem to want? (BTW, I do not know if it makes too much sense to specify width, height and keepaspectratio in includegraphics.) – marmot Jan 18 '18 at 23:03
  • like normal page breaking, longtable page breaking happens asynchronously the table rows, including background colour, are set before tex has decided where to split the pages. – David Carlisle Jan 18 '18 at 23:03
  • @David Carlisle: So is there a way around that? Longtable is a bit of a strange beast. – CGRemakes Jan 18 '18 at 23:06
  • oi, I take it you know the author of that software:-) – David Carlisle Jan 18 '18 at 23:07
  • lol, great package that has made things much easier, just requires some workarounds that are beyond my skillz. ;) – CGRemakes Jan 18 '18 at 23:12

Your Answer

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

Browse other questions tagged or ask your own question.