9

I'm in the unfortunate situation that I have to make a table in LaTeX which has thick vertical lines. Since this does not seem to be possible with the default tabular environment, I chose the tabu package. I know that there has been some discussion about its further usability about one year ago, but I found no other possibility, so I decided to give it a try.

It works well for me at all, but there is one horizontal line in my Layout, which is thick only half the way, so the vertical lines end to early for the thin parts, leaving ugly gaps.

This is the Layout:

enter image description here

And this is what I currently got:

enter image description here

Produced by this code:

%Dokumentclass
\documentclass[landscape]{letter}

%Packages
\usepackage[landscape]{geometry}
\usepackage[utf8]     {inputenc}
\usepackage           {multirow}
\usepackage           {tabu}

%Formatting
\pagestyle{empty} %Remove numbering

\begin{document}
  \begin{tabu}{ |[1pt] l | l l | l | l |[1pt] }
                                                                                                                 \tabucline[1 pt]{1-5}
    \multicolumn{2}{ |[1pt] l }{ } & \multicolumn{3}{ |[1pt] l |[1pt]}{ }                                     \\                       \hline
    &                              & \multicolumn{1}{ |[1pt] l |     }{ } & \multicolumn{2}{  l |[1pt] }{ }   \\                       \hline
    &                              & \multicolumn{1}{ |[1pt] l |     }{ } & \multicolumn{2}{  l |[1pt] }{ }   \\ \tabucline[1 pt]{3-5} \hline
    &                              & \multicolumn{1}{ |[1pt] l |     }{ } &                                 & \\                       \hline
    &                              & \multicolumn{1}{ |[1pt] l |     }{ } &                                 & \\                       \hline
    &                              & \multicolumn{1}{ |[1pt] l |     }{ } &                                 & \\                       \hline
    &                              & \multicolumn{1}{ |[1pt] l |     }{ } &                                 & \\ \tabucline[1 pt]{1-5}
  \end{tabu}
\end{document}

Except for the fact, that some resizing has to be done, you can see the gaps in the third row at the first and second column.

I haven't found any solution yet. Is this problem even solvable with tabu? Are there any other packages for this purpose?

4
  • 1
    Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.
    – Adam Liter
    Commented Jan 15, 2015 at 20:11
  • I added the missing parts, it should be compilable now without unnecessary additional work. Thank you for the advice!
    – Wanderer
    Commented Jan 15, 2015 at 20:25
  • Please see my revision for 2nd (perhaps preferable) approach. Commented Jan 15, 2015 at 20:43
  • Note that the tabu package has been unmaintained for quite a while and its use is discouranged as per today (August 2023). Commented Aug 14, 2023 at 12:47

2 Answers 2

8

One way is to shift up the skip prior to the mid-height \tabucline with a \\[-1pt]. See below for 2nd approach.

%Dokumentclass
\documentclass[landscape]{letter}

%Packages
\usepackage[landscape]{geometry}
\usepackage[utf8]     {inputenc}
\usepackage           {multirow}
\usepackage           {tabu}

%Formatting
\pagestyle{empty} %Remove numbering

\begin{document}
  \begin{tabu}{ |[1pt] l | l l | l | l |[1pt] }
                                                                                                                 \tabucline[1 pt]{1-5}
    \multicolumn{2}{ |[1pt] l }{ } & \multicolumn{3}{ |[1pt] l |[1pt]}{ }                                     \\                       \hline
    &                              & \multicolumn{1}{ |[1pt] l |     }{ } & \multicolumn{2}{  l |[1pt] }{ }   \\                       \hline
 y   &                              & \multicolumn{1}{ |[1pt] l |     }{ } & \multicolumn{2}{  l |[1pt] }{ }   \\[-1pt]   \tabucline[1 pt]{3-5} 
\hline
 x   &                              & \multicolumn{1}{ |[1pt] l |     }{ } &                                 & \\                       \hline
    &                              & \multicolumn{1}{ |[1pt] l |     }{ } &                                 & \\                       \hline
    &                              & \multicolumn{1}{ |[1pt] l |     }{ } &                                 & \\                       \hline
    &                              & \multicolumn{1}{ |[1pt] l |     }{ } &                                 & \\ \tabucline[1 pt]{1-5}
  \end{tabu}
\end{document}

enter image description here


Alternately, if you want the thin line to bisect the thick line, then the approach: \\[-1pt] \tabucline[1 pt]{3-5}\\[-12.5pt]\hline works.

%Dokumentclass
\documentclass[landscape]{letter}

%Packages
\usepackage[landscape]{geometry}
\usepackage[utf8]     {inputenc}
\usepackage           {multirow}
\usepackage           {tabu}

%Formatting
\pagestyle{empty} %Remove numbering

\begin{document}
  \begin{tabu}{ |[1pt] l | l l | l | l |[1pt] }
                                                                                                                 \tabucline[1 pt]{1-5}
    \multicolumn{2}{ |[1pt] l }{ } & \multicolumn{3}{ |[1pt] l |[1pt]}{ }                                     \\                       \hline
    &                              & \multicolumn{1}{ |[1pt] l |     }{ } & \multicolumn{2}{  l |[1pt] }{ }   \\                       \hline
 y   &                              & \multicolumn{1}{ |[1pt] l |     }{ } & \multicolumn{2}{  l |[1pt] }{ }   \\[-1pt]   \tabucline[1 pt]{3-5}\\[-12.5pt]
\hline
 x   &                              & \multicolumn{1}{ |[1pt] l |     }{ } &                                 & \\                       \hline
    &                              & \multicolumn{1}{ |[1pt] l |     }{ } &                                 & \\                       \hline
    &                              & \multicolumn{1}{ |[1pt] l |     }{ } &                                 & \\                       \hline
    &                              & \multicolumn{1}{ |[1pt] l |     }{ } &                                 & \\ \tabucline[1 pt]{1-5}
  \end{tabu}
\end{document}

enter image description here

1
  • I prefer the 2nd approach, the problem with the thin line not bisecting the thick one has been the next one on my list. Thank you for your effort, I never thought that the solution might be that easy.
    – Wanderer
    Commented Jan 15, 2015 at 20:57
2

You can do that with {NiceTabular} of nicematrix. With that environment, the key hvlines will draw all the rules excepted in the blocks created by \multicolumn and \Block (that command of nicematrix is not used in this example).

nicematrix creates PGF/Tikz nodes under the cells, rows and columns of the array. It's possible to use those nodes with Tikz to draw whatever rule you want. In the following code, I have drawn the heavy rules with Tikz.

\documentclass{article}

\usepackage{nicematrix,tikz}

\pagestyle{empty}

\begin{document}

\begin{NiceTabular}{lllll}[hvlines]
\Block{1-2}{ } && \Block{1-3}{} \\
    &  &  & \Block{1-2}{} \\ 
 y  &  &  & \Block{1-2}{} \\
 x  &  &  &  & \\
    \\
    \\
    \\
\CodeAfter
\begin{tikzpicture}
\draw [line width = 1pt]
  (1-|1) rectangle (8-|6) 
  (1-|3) -- (8-|3) 
  (4-|3) -- (4-|6) ;
\end{tikzpicture}
\end{NiceTabular}
\end{document}

You need several compilations because the PGF/Tikz nodes are written on the aux file.

Ouput of the first code

It's also possible to draw the thick rules with instructions \Block (using the key draw to draw the frame and line-width to specify the thickness of the rules).

\documentclass{article}
\usepackage{nicematrix}

\pagestyle{empty}

\NewDocumentCommand{\ThickFrame}{}{\Block[transparent,draw,line-width=1pt]}

\begin{document}

\begin{NiceTabular}{lllll}[hvlines]
\ThickFrame{*-2}{}
\Block{1-2}{ } && \ThickFrame{3-*}{}
                  \Block{1-3}{} \\
    &  &  & \Block{1-2}{} & \\ 
 y  &  &  & \Block{1-2}{} \\
 x  &  & \ThickFrame{*-*}{} \\
    \\
    \\
    \\
\end{NiceTabular}
\end{document}

Output of the second code

With that technic, you don't use TikZ (even though nicematrix uses PGF, the sublayer of TikZ under the hood).

You must log in to answer this question.

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