tabular: thicker lines

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}

enter image description here


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}

enter image description here


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][5][leftframe=custom,leftrulethickness=2pt]
\setupTABLE[row][5][topframe=custom,toprulethickness=2pt]
\setupTABLE[row][7][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

enter image description here


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%
  \advance\@multispan\m@ne
  \ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
  \@multicnt#3%
  \advance\@multicnt-#2%
  \advance\@multispan\@ne
  \leaders\hrule\@height#1\hfill
  \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.

enter image description here

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}

enter image description here

Tags:

Tables