1

I need to add some dividing rows to a longtable to set apart different sections. The Word template I'm working off of has dividing lines like so:

Example rows

My current attempt to replicate this uses three hlines and changes \arrayrulewidth and \arrayrulecolor for the middle one. Some example code:

\documentclass[letterpaper,10pt]{article} 
\usepackage[margin=.5in]{geometry}
\usepackage[table]{xcolor}
\usepackage{longtable}
\usepackage{array}
\usepackage{multicol}
\begin{document}
\arrayrulecolor{red}
\begin{longtable}{|m{1.5in}|m{2.5in}|m{2.5in}|}
\hline
Section 1 & Scales 1 & Subscales 1 \\
\hline
\noalign{\global\arrayrulewidth=4pt}\arrayrulecolor{blue}
\hline
\noalign{\global\arrayrulewidth=.4pt}\arrayrulecolor{red}
\hline
Section 2 & Scales 2 & Subscales 2 \\
\hline
\end{longtable}
\end{document}

However, this causes a break in the outer border and looks a little awkward: Current code example

Is there some workaround to get the border to show, or is there an alternate way of achieving this?

2 Answers 2

1

This is easy to do with \hhline:

\documentclass[letterpaper,10pt]{article}
\usepackage[margin=.5in]{geometry}
\usepackage[table]{xcolor}
\usepackage{longtable}
\usepackage{array, hhline}
\usepackage{multicol}

\begin{document}

\arrayrulecolor{red}
\setlength{\doublerulesep }{4pt}
\doublerulesepcolor{blue}
\begin{longtable}{|m{1.5in}|m{2.5in}|m{2.5in}|}
\hhline{|-|-|-|}
Section 1 & Scales 1 & Subscales 1 \\
\hhline{|=|=|=|}
Section 2 & Scales 2 & Subscales 2 \\
\hhline{|-|-|-|}
\end{longtable}
\arrayrulecolor{black}
\doublerulesepcolor{white}

\end{document} 

enter image description here enter image description here

2
  • The group around thelongtable suggests that it will limit the scope of the \arrayrulecolor and \doublerulesepcolor but it won't (these affectations are global). It would be clearer for the reader to put these instructions outside the group. Aug 22, 2019 at 15:20
  • That's right. Thanks for pointing the problem. I'll fix the code instantly.
    – Bernard
    Aug 22, 2019 at 15:31
0

For information, here is what you can do with {NiceTabular} of nicematrix with a perfect output (you won't see thin white lines as you see with hhline). However, nicematrix provides no breakable environment.

\documentclass[10pt]{article}
\usepackage{xcolor}
\usepackage{nicematrix,tikz}

\NiceMatrixOptions
 {
   custom-line = 
    {
      command = doubleline ,
      tikz = 
       { 
         draw = red , 
         double = blue , 
         shorten < = 0.5 \arrayrulewidth ,
         shorten > = 0.5 \arrayrulewidth ,
       } ,
      total-width = 3 \arrayrulewidth  ,
    }
 }

\begin{document}

\begin{NiceTabular}{|ccc|}[rules/color=red]
one & two & three \\
four & five & six \\
\doubleline
seven & eight & nine \\
ten & eleven & twelve \\
\end{NiceTabular}

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code

You must log in to answer this question.

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