1

Here's the MWE (I'm using MikTeX 2.9 in combination with TeXworks):

\documentclass[a4paper, 11pt]{article}

\usepackage{geometry}
\geometry{a4paper, portrait, left=2cm, right=2cm, top=3cm, bottom=3cm}

\usepackage[table]{xcolor}
\usepackage{multirow}
\usepackage{hhline}

\begin{document}
\thispagestyle{empty}
\definecolor{tch}{gray}{0.4}
\definecolor{tc3}{gray}{0.85}
\definecolor{tc4}{gray}{0.80}

\newcommand{\hlc}[1]{\cellcolor{tc3}\centering{}#1}
\newcommand{\hld}[1]{\cellcolor{tc4}\centering{}#1}
\newcommand{\hldx}[1]{\cellcolor{tc4}#1}
\newcommand{\hc}{\cellcolor{tc3}\ }
\newcommand{\hd}{\cellcolor{tc4}\ }

\setlength\arrayrulewidth{1pt}
\begin{tabular}{%
>{\raggedright}p{7.5em}!{\color{white}\vrule width 0.8pt}%
>{\raggedright}p{7.5em}!{\color{white}\vrule width 0.8pt}%
>{\raggedright}p{7.5em}!{\color{white}\vrule width 0.8pt}%
>{\raggedright\arraybackslash}p{11em}!{\color{white}\vrule width 0.8pt}%
}
\arrayrulecolor{white}\hline\rowcolor{tch}
   \color{white}{\bf Left preamp} & 
   \color{white}{\bf Right preamp} & 
   \color{white}{\bf Wiring} &
   \color{white}{\bf Description} \\
\hld{AUDIO-L\\(O)} &\hlc            &\hld{25\,cm (10\,in) shielded}&\hldx{Voice output x}\\
\hline
\hld{AGC-L\\(O)}   &\hlc            &\hld{15\,cm (6\,in)  shielded}&\hldx{Voice output y}\\
\hline
\hld{EXC-L\\(O)}   &\hld{abcd\\(I)} &\hld{20\,cm (8\,in)  shielded}&\hldx{Voice output z}\\
\hline
\hlc               &\hlc            &\hld{25\,cm (10\,in) shielded}&\hd\\
\hhline{=--~}
\hlc               &\hlc            &\hld{25\,cm (10\,in) shielded}&\multirow{-2}={\hldx{Excitation signals for both sides of the xyz}} \\
\hline
\end{tabular}

\end{document}

The result looks like this:

enter image description here

I wouldn't expect the double horizontal line to go beyond the first column. The use of \hhline{=--~} is just an example for better visualization. What I actually want to use is \hline{---~}. \cline doesn't work at all in this situation (no line shows up). How do I make sure I don't get a line cut across my multirow cell?

Unrelated to my main question, I don't know where the extra space above the text in the headers is coming from.

1

one way to make line through multirow cell invisible is to color it:

\documentclass[a4paper, 11pt]{article}

\usepackage{geometry}
\geometry{a4paper, portrait, hmargin=2cm, vmargin=3cm}

\usepackage[table]{xcolor}
\usepackage{multirow}
\usepackage{hhline}

\begin{document}
\thispagestyle{empty}
\definecolor{tch}{gray}{0.4}
\definecolor{tc3}{gray}{0.85}
\definecolor{tc4}{gray}{0.80}

\newcommand{\hlc}[1]{\cellcolor{tc3}\centering{}#1}
\newcommand{\hld}[1]{\cellcolor{tc4}\centering{}#1}
\newcommand{\hldx}[1]{\cellcolor{tc4}#1}
\newcommand{\hc}{\cellcolor{tc3}\ }
\newcommand{\hd}{\cellcolor{tc4}\ }

\setlength\arrayrulewidth{1pt}
\begin{tabular}{%
>{\raggedright}p{7.5em}!{\color{white}\vrule width 0.8pt}%
>{\raggedright}p{7.5em}!{\color{white}\vrule width 0.8pt}%
>{\raggedright}p{7.5em}!{\color{white}\vrule width 0.8pt}%
>{\raggedright\arraybackslash}p{11em}%
}
\arrayrulecolor{white}\hline\rowcolor{tch}
   \color{white}{\bf Left preamp} &
   \color{white}{\bf Right preamp} &
   \color{white}{\bf Wiring} &
   \color{white}{\bf Description} \\
\hld{AUDIO-L\\(O)} &\hlc            &\hld{25\,cm (10\,in) shielded}&\hldx{Voice output x}\\
\hline
\hld{AGC-L\\(O)}   &\hlc            &\hld{15\,cm (6\,in)  shielded}&\hldx{Voice output y}\\
\hline
\hld{EXC-L\\(O)}   &\hld{abcd\\(I)} &\hld{20\,cm (8\,in)  shielded}&\hldx{Voice output z}\\
\hline
\hlc               &\hlc            &\hld{25\,cm (10\,in) shielded}&\hd\\
\hhline{--->{\arrayrulecolor{tc4}}-}  % <---
\hlc               &\hlc            &\hld{25\,cm (10\,in) shielded} &\multirow{-2}={\hldx{Excitation signals for both sides of the xyz}} \\
\hline
\end{tabular}
\end{document}

enter image description here

edit:

in case that you like to have thicker line between last two rows (as you show in image in question, than you should change used \hhline{=--~} with

\hhline{--->{\arrayrulecolor{tc4}\doublerulesepcolor{tc4}}=}  % <---

instead of \hhline{--->{\arrayrulecolor{tc4}}-} % <--- in mwe above. than you will obtain:

enter image description here

2
  • Oh, that works quite well indeed. Thanks for your help.One thing though, in case there are more \hline and \hhline to follow, the color needs to be set back. In my case: \hhline{--->{\arrayrulecolor{tc4}}->{\arrayrulecolor{white}}}
    – Hansel
    Aug 18 '18 at 13:03
  • @Hansel, change color is for all line segments after change of color (until you change it again). for details how to color \hhline see documentation of the package colortbl, page 6.
    – Zarko
    Aug 18 '18 at 13:12
1

The trick is to draw a full hhline, with the last segment of the color of the background. I took the opportunity to simplify your code, with the \columncolor command. The unwanted vertical spacing in the first row is solved with the \thead command from makecell:

\documentclass[a4paper, 11pt]{article}

\usepackage{geometry}
\geometry{a4paper, portrait, left=2cm, right=2cm, top=3cm, bottom=3cm}

\usepackage[table]{xcolor}
\usepackage{multirow}
\usepackage{hhline}
\usepackage{makecell}

\begin{document}
\thispagestyle{empty}
\definecolor{tch}{gray}{0.4}
\definecolor{tc3}{gray}{0.85}
\definecolor{tc4}{gray}{0.80}

\newcommand{\hlc}[1]{\cellcolor{tc3}\centering{}#1}

\setlength\arrayrulewidth{1pt}
\setlength{\extrarowheight}{2pt}
\renewcommand{\theadfont}{\raggedright\normalsize\bfseries\color{white}}
\renewcommand{\theadalign}{l}
\begin{tabular}{
*{3}{>{\columncolor{tc4}\centering}p{7.5em}!{\color{white}\vrule width 0.8pt}}%
>{\columncolor{tc4}\raggedright\arraybackslash}p{11em}!{\color{white}\vrule width 0.8pt}%
}
\arrayrulecolor{white}\hline\rowcolor{tch}
 \thead{Left preamp }&
   \thead{Right preamp} &
   \thead{Wiring} &
   \thead{Description} \\
 AUDIO-L\\(O) &\hlc & 25\,cm (10\,in) shielded & Voice output x \\
\hline
AGC-L\\(O) &\hlc & 15\,cm (6\,in) shielded & Voice output y \\
\hline
EXC-L\\(O) & abcd\\(I) & 20\,cm (8\,in) shielded & Voice output z \\
\hline
\hlc &\hlc & 25\,cm (10\,in) shielded & \\
\hhline{---|>{\arrayrulecolor{tc4}}->{\arrayrulecolor{white}}}
\hlc &\hlc & 25\,cm (10\,in) shielded & \multirow{-2}={Excitation signals for both sides of the xyz} \\
\hline
\end{tabular}

\end{document}

enter image description here

2
  • Thanks for the tip with makecell. The problem though is that if the text is wider than the assigned field width, it doesn't do a linebreak.
    – Hansel
    Aug 18 '18 at 13:30
  • Yes, but I think that for a column head, which is not ordinary text, it's better to choose the break point.
    – Bernard
    Aug 18 '18 at 13:34

This site is temporarily in read only mode and not accepting new answers.

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