Graphics, Figures & Tableslongtable and colored rules?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
rscottbailey
Posts: 3
Joined: Fri Apr 01, 2016 5:35 pm

longtable and colored rules?

Post by rscottbailey »

What am I doing wrong? The following code compiles cleanly but does not produce the desired result:

Code: Select all

\documentclass{article}

\usepackage{longtable}
\usepackage{booktabs}
\usepackage{colortbl}

\newcommand\mytoprule{
  \arrayrulecolor{red} % This seems to have no effect :(
  \toprule[4.5pt]
  \arrayrulecolor{black}
}

\begin{document}

\begin{longtable}{ll}
\caption{Sample Table} \\
\textbf{Column} & \textbf{Column} \\
\mytoprule
\endfirsthead
\bottomrule[2.25pt]
\endlastfoot
 This doesn't work & like it should \\\hline
 I want colored line & above \\\hline
 and black line & below \\
\end{longtable}

\end{document}
My resulting PDF document shows a black rule:
rsbbug.pdf
Output generated from sample LaTeX source
(12.62 KiB) Downloaded 342 times
Experimentation with the actual (much longer) document suggests the \arrayrulecolor command is affecting regular tabular objects, but not longtable objects. I'm stumped.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

longtable and colored rules?

Post by mas »

It is working as expected here. Here is how it looks:
x.png
x.png (17.18 KiB) Viewed 5649 times
Or is it now what you are expecting?

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
rscottbailey
Posts: 3
Joined: Fri Apr 01, 2016 5:35 pm

Re: longtable and colored rules?

Post by rscottbailey »

That's exactly what I was expecting.

I appreciate the sanity check... I guess now I will start comparing the current versions of the packages in question with the ones bundled with RHEL 5 and see what is needed to reproduce your results.
rscottbailey
Posts: 3
Joined: Fri Apr 01, 2016 5:35 pm

Re: longtable and colored rules?

Post by rscottbailey »

I just wanted to close the loop on this in case it helps somebody else.

RHEL 5 supplies booktabs v1.618. Using booktabs v1.61803 retrieved from CTAN corrected my problem, and colored rules in longtables now work correctly.
Post Reply