1

I can not get the border of this minimal example to look correct, the \colorcell command is overwriting the lines:

\documentclass[11pt]{article}
\usepackage{xcolor}
\usepackage[margin=.9in]{geometry}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage{hhline}

\pagestyle{plain}
\setlength\parindent{0pt}

\begin{document}
\setlength{\arrayrulewidth}{.8pt}


\begin{tabular}{ | c | c | c | c | } 
\hhline{----}
\cellcolor{red!30!white}\textbf{} & 
\cellcolor{red!30!white}\textbf{} &\multicolumn{1}{|c|}{\cellcolor{red!30!white}\textbf{Text}} & \multicolumn{1}{|c|}{\cellcolor{red!30!white}\textbf{Text}} \\ 
\hhline{|~|~|~|~|}
\multirow{-2}{*}{\cellcolor{red!30!white}\textbf{Text}} & 
\multirow{-2}{*}{\cellcolor{red!30!white}\textbf{Text}} 
&\multicolumn{1}{|c|}{\cellcolor{red!30!white}\textbf{Text}} 
& \multicolumn{1}{|c|}{\cellcolor{red!30!white}\textbf{Text}} \\ 
\hhline{----}
Text & &\begin{minipage}{.6\textwidth}
\begin{itemize} \itemsep-0.4em
\vspace{1mm}
\item Text
\item Text
\vspace{1mm}
\end{itemize}
\end{minipage} &\\
\hhline{----}
Text & &\begin{minipage}{.6\textwidth}
\begin{itemize} \itemsep-0.4em
\vspace{1mm}
\item Text
\item Text
\vspace{1mm}
\end{itemize}
\end{minipage} &\\
\end{tabular}

\end{document}

This outputs:

enter image description here

Advise how to correct.

2
  • I don't understand your problem. I can see you have two double vertical rules limiting the third column, that' all. Can you explain more?
    – Bernard
    Jul 26, 2019 at 23:23
  • @Bernard, the problem is achieving uniform thickness in the colorcell areas. Jul 26, 2019 at 23:27

2 Answers 2

2

Here is a solution, using the makecell package, which allows for line breaks in standard cells, and enumitem, which makes it easy to set parameters for lists, and define new list tpypes. So I defined a tabitemize list, with parameters adapted to lists in tabulars. Last change: the 3rd column is now p{0.6\textwidth}, so you have no more to use minipages inside cells. Note that loading xcolor with option table automatically loads colortbl and defines a new command: \rowcolors.

\documentclass[11pt]{article}
\usepackage[table]{xcolor}
\usepackage[margin=.9in]{geometry}
\usepackage{multirow}
\usepackage{hhline}
\usepackage{makecell}
\pagestyle{plain}
\setlength\parindent{0pt}

\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother
\usepackage{enumitem}
 \newlist{tabitemize}{itemize}{1}
\setlist[tabitemize]{wide=0pt, label=\textbullet, leftmargin=*, nosep, after=\vspace*{-\baselineskip}}

\begin{document}

\setlength{\arrayrulewidth}{.8pt}
\renewcommand{\cellset}{\bfseries}
\setlength{\extrarowheight}{3pt}
\begin{tabular}{ | c | c |>{\arraybackslash\compress}p{0.6\textwidth} | c | }%
\hhline{----}
\rowcolor{red!30!white}\makecell{Text} & \makecell{Text} &\makecell{Text\\Text}& \makecell{Text\\Text} \\
\hhline{----}
Text & &
\begin{tabitemize}
\item Text
\item Text
\end{tabitemize}
 &\\
\hhline{----}
Text & &
\begin{tabitemize}
\item Text
\item Text
\end{tabitemize}
 &\\
\end{tabular}

\end{document} 

enter image description here

5
  • Of course there other solutions. But I also wanted to simplify your code, avoiding the use of multirow in particular, which I felt unnecessary here.
    – Bernard
    Jul 27, 2019 at 0:51
  • yes I notice the borders are still temperamental. There are other packages which do tables as well Jul 27, 2019 at 13:15
  • With the code I propose, the cells borders have uniform thickness. Your problem with borders was dues to wrong specifications of \multicolumn. I don't use this command any more.
    – Bernard
    Jul 27, 2019 at 13:43
  • +1! for use of \cellset. in definition of the tabitemize option leftmargin=* overwrite wide=0pt. which wane should be active?
    – Zarko
    Dec 24, 2019 at 21:57
  • For me wide=0pt and leftmargin=*` are complementary: we have both the bullet at the very beginning of the cell, and the default hanging indent for the text of the item. Did I misunderstand how these parameters work?
    – Bernard
    Dec 24, 2019 at 22:06
2

With {NiceTabular} of nicematrix, you have directly a perfect output : the rules won't seem to vanish in some PDF viewers at some levels of zoom.

\documentclass[11pt]{article}
\usepackage{xcolor}
\usepackage[margin=.9in]{geometry}
\usepackage{nicematrix}

\setlength\parindent{0pt}

\begin{document}
\setlength{\arrayrulewidth}{.8pt}

\begin{NiceTabular}{cccc}[vlines]
\hline
\RowStyle[nb-rows=2,bold,rowcolor=red!30]{}
\Block{2-1}{Text} & \Block{2-1}{Text} & Text & Text \\
& & Text & Text \\
\hline
Text & &\begin{minipage}{.6\textwidth}
\begin{itemize} \itemsep-0.4em
\vspace{1mm}
\item Text
\item Text
\vspace{1mm}
\end{itemize}
\end{minipage} &\\
\hline
Text & &\begin{minipage}{.6\textwidth}
\begin{itemize} \itemsep-0.4em
\vspace{1mm}
\item Text
\item Text
\vspace{1mm}
\end{itemize}
\end{minipage} &\\
\end{NiceTabular}

\end{document}

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

Output of the above code

You must log in to answer this question.

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