# tabular: thicker lines

\begin{tabular}{|c|c|c|c|c|c|}
\hline
\multicolumn{2}{|c|}{Foo} & \multicolumn{4}{|c|}{Bar} \\ \hline
\multicolumn{2}{|c}{} & \multicolumn{2}{|c|}{BarA} & \multicolumn{2}{|c|}{BarB} \\ \hline
\multicolumn{2}{|c|}{} & $\lambda$ & $\theta$ & $\lambda$ & $\theta$ \\ \hline
\multirow{2}{*}{FooA} & $\mu$ & 2 & 3 & 8 & 9\\ \cline{2-6}
& $\pi$ & 5 & 6 & 7 & 9 \\ \hline
\multirow{2}{*}{FooB} & $\mu$ & 2 & 3 & 8 & 9 \\ \cline{2-6}
& $\pi$ & 5 & 6 & 7&10 \\
\hline
\end{tabular}


hi, how could I draw a thicker horizontal line between the lines of FooA and those of FooB and also a thicker vertical line between BarA and BarB?

I've tried many solutions found on the Web, but all of them cause some alignment error.

edit: To clarify in the real table that I'm building I have many Foo columns (FooA, FooB, FooC,...) and many Bar rows (BarA, BarB, BarC,...). If the lines are all equals it's hard to tell to which Foo column and to which Bar row a number belongs. So I want to make thick lines to separate the Foo columns and the Bar rows.

• – Robert H Jun 15 '16 at 20:21
• @RobertH No, the question you linked only refers to horizontal lines and is therefore merely related. – Henri Menke Jun 16 '16 at 7:30

In LaTeX you can do it with tabu. For the thickened \cline (which is now \tabucline[1pt]{2-6}) to not create a gap in the outer frame, one has to “undo” the vertical space added by the rule by annotating the preceding linebreak \\[-1pt].

\documentclass{article}
\usepackage{tabu,multirow}
\begin{document}

\begin{tabu}{|c|c|c|c|[1pt]c|c|}
\hline
\multicolumn{2}{|c|}{Foo} & \multicolumn{4}{c|}{Bar} \\ \hline
\multicolumn{2}{|c|}{} & \multicolumn{2}{c|[1pt]}{BarA} & \multicolumn{2}{c|}{BarB} \\ \hline
\multicolumn{2}{|c|}{} & $\lambda$ & $\theta$ & $\lambda$ & $\theta$ \\ \hline
\multirow{2}{*}{FooA} & $\mu$ & 2 & 3 & 8 & 9\\[-1pt] \tabucline[1pt]{2-6}
& $\pi$ & 5 & 6 & 7 & 9 \\ \hline
\multirow{2}{*}{FooB} & $\mu$ & 2 & 3 & 8 & 9 \\[-1pt] \tabucline[1pt]{2-6}
& $\pi$ & 5 & 6 & 7&10 \\
\hline
\end{tabu}

\end{document} If you don't want to use tabu (what I totally understand), then the boldline package might be for you. It introduces the following rules

• V{<factor>} vertical rule which is <factor> thicker than the normal vertical rule.
• \hlineB{<factor>} horizontal rule which is <factor> thicker than the normal horizontal rule.
• \clineB{<spec>}{<factor>} horizontal rule which spans the columns given in <spec> and which is <factor> thicker than the normal horizontal rule.

To obtain a rule of 1pt one has to replace two | by V{2.5} and the two \cline by \clineB{2-6}{2.5}.

\documentclass{article}
\usepackage{boldline,multirow}
\begin{document}

\begin{tabular}{|c|c|c|cV{2.5}c|c|}
\hline
\multicolumn{2}{|c|}{Foo} & \multicolumn{4}{c|}{Bar} \\ \hline
\multicolumn{2}{|c|}{} & \multicolumn{2}{cV{2.5}}{BarA} & \multicolumn{2}{c|}{BarB} \\ \hline
\multicolumn{2}{|c|}{} & $\lambda$ & $\theta$ & $\lambda$ & $\theta$ \\ \hline
\multirow{2}{*}{FooA} & $\mu$ & 2 & 3 & 8 & 9\\ \clineB{2-6}{2.5}
& $\pi$ & 5 & 6 & 7 & 9 \\ \hline
\multirow{2}{*}{FooB} & $\mu$ & 2 & 3 & 8 & 9 \\ \clineB{2-6}{2.5}
& $\pi$ & 5 & 6 & 7&10 \\
\hline
\end{tabular}

\end{document} • thanks that works perfectly (I've tried the boldline solution) – lambdauser Jun 15 '16 at 20:38
• @lambdauser Just an aside: I have updated all of your multicolumns because some rules were drawn twice. For example, if you have a row which reads \multicolumn{2}{|c|}{Foo} & \multicolumn{4}{|c|}{Bar} \\, then the right | of Foo is at the same position as the left | of Bar, which makes them overlap and appear thicker. As a convention, I always leave out the left | in multicolumns (unless the multicolumn is the first column in a line, then we must not omit the left |). – Henri Menke Jun 15 '16 at 20:44

Actually I had the same problem some years ago and redefined the tabular line commands. I have not uploaded to ctan and I am not sure I consider it a finalized work. Still, I think it works. To try, save the following as shtabularlines.sty.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Defines thick lines for use in tabular environments
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{shtabularlines}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Add an optional parameter for the line width to the command \hline,
%% \vline, and \cline:
%%
%% \shhline[width]
%% \shvline[width]
%% \shcline[width]{c1-c2}
%% \shclinespace[width]
%%
%% The default width is the same as standard lines. This is set by the
%% parameter \sharrayrulewidth. Reset with \renewcommand
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\sharrayrulewidth{\arrayrulewidth}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% \hline
\def\shhline{\noalign{\ifnum0=}\fi%
\@ifnextchar[{\sh@hline}{\sh@hline[\sharrayrulewidth]}}
\def\sh@hline[#1]{\hrule height #1 \futurelet\reserved@a\@xhline}
%% \vline
\def\shvline{%
\@ifnextchar[{\sh@vline}{\sh@vline[\sharrayrulewidth]}}
\def\sh@vline[#1]{\vrule \@width #1}
%% \clinespace
\def\shclinespace{\omit%
\@ifnextchar[{\sh@clinespace}{\sh@clinespace[\sharrayrulewidth]}}
\def\sh@clinespace[#1]{%
\cr
\hbox{\vrule height \arraystretch #1 width 0pt}
}
%% \cline
\def\shcline{\omit%
\@ifnextchar[{\sh@cline}{\sh@cline[\sharrayrulewidth]}}
\def\sh@cline[#1]#2{\sh@@cline[#1]#2\@nil}
\def\sh@@cline[#1]#2-#3\@nil{%
\@multicnt#2%
\ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
\@multicnt#3%
\cr
\noalign{\vskip -#1}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\endinput


Then you can use it according to the (brief) manual below. If the quality is too poor you can get a better at shtabularlines.pdf. As you can see my version of \cline has a problem since it does not set the space for the extra width. This is compensated by hand by \shclinespace.

So the following tabular environment gives the table below:

\renewcommand\sharrayrulewidth{1.5pt}
\begin{tabular}{|c|c|c|c!{\shvline}c|c|}\hline
\multicolumn{2}{|c|}{Foo} & \multicolumn{4}{c|}{Bar} \\ \hline
\multicolumn{2}{|c|}{} & \multicolumn{2}{c!{\shvline}}{BarA} & \multicolumn{2}{c|}{BarB} \\ \hline
\multicolumn{2}{|c|}{} & $\lambda$ & $\theta$ & $\lambda$ & $\theta$ \\ \hline
\multirow{2}{*}{FooA} & $\mu$ & 2 & 3 & 8 & 9\\ \shcline{2-6}\shclinespace[\sharrayrulewidth]
& $\pi$ & 5 & 6 & 7 & 9 \\ \hline
\multirow{2}{*}{FooB} & $\mu$ & 2 & 3 & 8 & 9 \\ \shcline{2-6}\shclinespace[\sharrayrulewidth]
& $\pi$ & 5 & 6 & 7&10 \\\hline
\end{tabular} • thanks it works almost perfectly but the vertical line is only partially drawn. It stops before BarA and BarB. – lambdauser Jun 15 '16 at 15:47
• @Stefan The boldline package might actually be doing the same as your shtabularlines is trying to achieve. – Henri Menke Jun 15 '16 at 17:36
• @lambdauser Did you update the \multicolumn spec also? I have updated with a version that works. But it might be a good idea to have a look at boldline also as suggested in the previous comment. – StefanH Jun 15 '16 at 19:48
• yes it works after fixing the \multicolumn issue – lambdauser Jun 16 '16 at 6:57

With ConTeXt MKIV and the custom frame extension by [Aditya (2012)]

\unprotect
\startuniqueMPgraphic {top_frame}
draw topboundary OverlayBox
withpen pensquare scaled (\the\dimexpr\framedparameter{\c!top\c!rulethickness}\relax)
withcolor \MPcolor{\framedparameter{\c!top\c!framecolor}} ;

setbounds currentpicture to OverlayBox ;
\stopuniqueMPgraphic

\startuniqueMPgraphic {left_frame}
draw leftboundary OverlayBox
withpen pensquare scaled (\the\dimexpr\framedparameter{\c!left\c!rulethickness}\relax)
withcolor \MPcolor{\framedparameter{\c!left\c!framecolor}} ;

setbounds currentpicture to OverlayBox ;
\stopuniqueMPgraphic

\installtopframerenderer{custom}{\uniqueMPgraphic{top_frame}}
\installleftframerenderer{custom}{\uniqueMPgraphic{left_frame}}

\setupframed
[
\c!top\c!rulethickness=\framedparameter\c!rulethickness,
\c!top\c!framecolor=\framedparameter\c!framecolor,
\c!left\c!rulethickness=\framedparameter\c!rulethickness,
\c!left\c!framecolor=\framedparameter\c!framecolor,
]
\protect

\setupTABLE[option=stretch]
\setupTABLE[each][align={middle,lohi}]
\setupTABLE[column][leftframe=custom,leftrulethickness=2pt]
\setupTABLE[row][topframe=custom,toprulethickness=2pt]
\setupTABLE[row][topframe=custom,toprulethickness=2pt]
\starttext
\startTABLE
\NC[nx=2] Foo  \NC[nx=4] Bar \NC\NR
\NC[nx=2]      \NC[nx=2] BarA \NC[nx=2] BarB \NC\NR
\NC[nx=2]      \NC $\lambda$ \NC $\theta$ \NC $\lambda$ \NC $\theta$ \NC\NR
\NC[ny=2] FooA \NC $\mu$ \NC 2 \NC 3 \NC 8 \NC 9\NC\NR
\NC $\pi$ \NC 5 \NC 6 \NC 7 \NC 9 \NC\NR
\NC[ny=2] FooB \NC $\mu$ \NC 2 \NC 3 \NC 8 \NC 9 \NC\NR
\NC $\pi$ \NC 5 \NC 6 \NC 7\NC 10 \NC\NR
\stopTABLE
\stoptext • thanks for the answer but I have to use it inside a latex project – lambdauser Jun 15 '16 at 15:49
• This is not a hack but the proper way to interface metapost borders. – Aditya Jun 16 '16 at 4:23
• @Aditya I changed »hack« into »extension«. Also, I found that the typo in pack-fen.mkiv (for which \let\setinstalledframedimensions\pack_framed_overlay_initialize_indeed` was needed) is gone by now. – Henri Menke Jun 16 '16 at 7:24