1

I'm trying to make a nice looking tabu, as part of a hand-in I'm working on. And if I simply use l,c or r as arguments for the columns, it looks good.

However, the problem arises when I try to define a width for the colums (p{3.75cm} in this case). The vertical lines meant to separate the lower part of the tabu into three parts, disappears.

enter image description here

This is how I'd like the tabu to look, only with pre-defined width for the columns like so:

enter image description here

Hower as you can see, the sepearion lines in this case are gone. How can I get them back?

\documentclass[danish]{report}

\usepackage[a4paper, headheight=14pt]{geometry}

\usepackage[table]{xcolor}
\usepackage{float}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{makecell}
\usepackage{tabu}

\usepackage{babel}

% Define colors
\definecolor{UMLetBlue}{RGB}{130,130,255}
\definecolor{UMLetGray}{RGB}{189,189,189}
\definecolor{UMLetGreen}{RGB}{130,255,130}
\definecolor{UMLetRed}{RGB}{255,130,130}
\definecolor{UMLetYellow}{RGB}{255,255,130}

\begin{document}

\begin{table}[H]
    \centering
    \taburowcolors 2 {white .. UMLetGray}
    \begin{tabu}{p{3.75cm}|p{3.75cm}|p{3.75cm}l}
        \multicolumn{1}{c}{\textbf{Scenarie}} & \multicolumn{1}{c}{\textbf{Resultat}} & \multicolumn{1}{c}{\textbf{Godkendt}} &  \\
        \hline
        A   &   B   &   C   &   \\
        D   &   E   &   F   &   \\
        G   &   H   &   I   &
    \end{tabu}
    \caption{My caption}
    \label{my-label}
\end{table}

\begin{table}[H]
    \centering
    \taburowcolors 2 {white .. UMLetGray}
    \begin{tabu}{l|l|ll}
        \multicolumn{1}{c}{\textbf{Scenarie}} & \multicolumn{1}{c}{\textbf{Resultat}} & \multicolumn{1}{c}{\textbf{Godkendt}} &  \\
        \hline
        A                                       & B                                      & C                                      &  \\
        C                                       & D                                      & E                                      &  \\
        F                                       & G                                      & H                                      & 
    \end{tabu}
    \caption{My caption2}
    \label{my-label2}
\end{table}

\end{document}
3
  • you meant vertical lines to be there from top row to bottom row? @Julnaz
    – Biki Teron
    May 26, 2017 at 12:06
  • Yes, like shown in [tabel 1]. I would like the row underneath the first one to be divided into 3, with a clear line between them.
    – Julnaz
    May 26, 2017 at 12:23
  • vertical line are on both images. you have pdf viewer issues.
    – Zarko
    May 27, 2017 at 7:10

2 Answers 2

1
\documentclass[danish]{report}

\usepackage[a4paper, headheight=14pt]{geometry}

\usepackage[table]{xcolor}
\usepackage{float}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{makecell}
\usepackage{tabu}

\usepackage{babel}

% Define colors
\definecolor{UMLetBlue}{RGB}{130,130,255}
\definecolor{UMLetGray}{RGB}{189,189,189}
\definecolor{UMLetGreen}{RGB}{130,255,130}
\definecolor{UMLetRed}{RGB}{255,130,130}
\definecolor{UMLetYellow}{RGB}{255,255,130}

\begin{document}

\begin{table}[H]
    \centering
    \taburowcolors 2 {white .. UMLetGray}
    \begin{tabu}{p{3.75cm}|p{3.75cm}|p{3.75cm}l}
        \multicolumn{1}{c|}{\textbf{Scenarie}} & \multicolumn{1}{c|}{\textbf{Resultat}} & \multicolumn{1}{c}{\textbf{Godkendt}} &  \\
        \hline
        A   &   B   &   C   &   \\
        D   &   E   &   F   &   \\
        G   &   H   &   I   &
    \end{tabu}
    \caption{My caption}
    \label{my-label}
\end{table}

\begin{table}[H]
    \centering
    \taburowcolors 2 {white .. UMLetGray}
    \begin{tabu}{l|l|ll}
        \multicolumn{1}{c|}{\textbf{Scenarie}} & \multicolumn{1}{c|}{\textbf{Resultat}} & \multicolumn{1}{c}{\textbf{Godkendt}} &  \\
        \hline
        A                                       & B                                      & C                                      &  \\
        C                                       & D                                      & E                                      &  \\
        F                                       & G                                      & H                                      & 
    \end{tabu}
    \caption{My caption2}
    \label{my-label2}
\end{table}

\end{document}

enter image description here

New modified code

\documentclass[danish]{report}

\usepackage[a4paper, headheight=14pt]{geometry}

\usepackage[table]{xcolor}
\usepackage{float}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{makecell}
\usepackage{tabu}

\usepackage{babel}

% Define colors
\definecolor{UMLetBlue}{RGB}{130,130,255}
\definecolor{UMLetGray}{RGB}{189,189,189}
\definecolor{UMLetGreen}{RGB}{130,255,130}
\definecolor{UMLetRed}{RGB}{255,130,130}
\definecolor{UMLetYellow}{RGB}{255,255,130}

\begin{document}

\begin{table}[H]
    \centering
    \taburowcolors 2 {white .. UMLetGray}
    \begin{tabu}{p{3.75cm}|p{3.75cm}|p{3.75cm}l}
        \multicolumn{1}{c}{\textbf{Scenarie}} & \multicolumn{1}{c}{\textbf{Resultat}} & \multicolumn{1}{c}{\textbf{Godkendt}} &  \\
        \hline
        A   &   B   &   C   &   \\
        D   &   E   &   F   &   \\
        G   &   H   &   I   &
    \end{tabu}
    \caption{My caption}
    \label{my-label}
\end{table}

\begin{table}[H]
    \centering
    \taburowcolors 2 {white .. UMLetGray}
    \begin{tabu}{l|l|ll}
        \multicolumn{1}{c}{\textbf{Scenarie}} & \multicolumn{1}{c}{\textbf{Resultat}} & \multicolumn{1}{c}{\textbf{Godkendt}} &  \\
        \hline
        A                                       & B                                      & C                                      &  \\
        C                                       & D                                      & E                                      &  \\
        F                                       & G                                      & H                                      & 
    \end{tabu}
    \caption{My caption2}
    \label{my-label2}
\end{table}

\end{document}

enter image description here

1
  • Thank you for the quick reply. While this does indeed give me back the seperation lines in the lower tabel, I was hoping for a solution that would still leave them out of the top part Scenarie Resultat Godkendt Do you know if this is possible?
    – Julnaz
    May 27, 2017 at 6:38
0

With {NiceTabular} of nicematrix. The vertical rules won't disappear, whatever PDF viewer you use.

\documentclass[danish]{report}
\usepackage[a4paper, headheight=14pt]{geometry}
\usepackage{xcolor}
\usepackage{float}
\usepackage{nicematrix}

\usepackage{babel}

% Define colors
\definecolor{UMLetBlue}{RGB}{130,130,255}
\definecolor{UMLetGray}{RGB}{189,189,189}
\definecolor{UMLetGreen}{RGB}{130,255,130}
\definecolor{UMLetRed}{RGB}{255,130,130}
\definecolor{UMLetYellow}{RGB}{255,255,130}

\begin{document}

\begin{table}[H]
\centering
\begin{NiceTabular}{p{3.75cm}|p{3.75cm}|p{3.75cm}}
\CodeBefore
  \rowcolors{2}{white}{UMLetGray}
\Body
  \RowStyle{\bfseries\centering}\Block{1-*}{}
  Scenarie & Resultat & Godkendt \\
  \hline
  A & B & C \\
  C & D & E \\
  F & G & H 
\end{NiceTabular}
\caption{My caption2}
\label{my-label2}
\end{table}



\begin{table}[H]
\centering
\begin{NiceTabular}{l|l|l}
\CodeBefore
  \rowcolors{2}{white}{UMLetGray}
\Body
  \RowStyle{\bfseries}\Block{1-*}{}
  Scenarie & Resultat & Godkendt \\
  \hline
  A & B & C \\
  C & D & E \\
  F & G & H 
\end{NiceTabular}
\caption{My caption2}
\label{my-label2}
\end{table}

\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 .