# Bold line around one cell

I want a bold line around only one cell. The problem is that the cells below and on the sides are colored with \cellcolor so \cline didn't work. I then found this solution which produced bold lines on all sides of the cell. Highlight table cells using thick, colored border But I didn't want it to change the height of the cell and I don't know what to change so the lines on the right and left don't stop before tabcolsep.

\documentclass[11pt]{article}

\usepackage[ngerman]{babel}
\usepackage[a4paper, text={16.5cm, 25.2cm}, centering]{geometry}
\usepackage[sfdefault]{ClearSans}
\usepackage[utf8]{inputenc}
\setlength{\parskip}{1.2ex}
\setlength{\parindent}{0em}

\usepackage{tabularx}

\usepackage[dvipsnames]{xcolor}
\usepackage{colortbl}

\makeatletter
\def\highlight#1{%
\fboxrule2pt %
\hsize=\dimexpr\hsize-2\fboxrule-2\fboxsep\relax
#1%
\@endpbox\unskip\setbox0\lastbox\bgroup
\fboxrule2pt %
\fcolorbox{black}{white}{\box0}\hfill}

\begin{document}

\center{hiragana test :)}

\vspace{12pt}

\begin{center}

\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}

\setlength{\extrarowheight}{0.8cm}
\begin{tabular}{|C{1.5cm}|C{1.5cm}|C{1.5cm}|C{1.5cm}|C{1.5cm}|C{1.5cm}|}

\hline
& a & i & u & e & o \\
\hline
\cellcolor{gray!60} & & & & &  \\
\hline
k & & & & &  \\
\hline
s & & & & &  \\
\hline
t & & & & &  \\
\hline
n & & & & &  \\
\hline
h & & & & &  \\
\hline
m & & & & &  \\
\hline
y & & & & &  \\
\hline
r & & & & &  \\
\hline
w & &\cellcolor{gray!60} & \cellcolor{gray!60}& \cellcolor{gray!60}&  \\
\hline
n & \highlight{} &\cellcolor{gray!60} &\cellcolor{gray!60} &\cellcolor{gray!60} & \cellcolor{gray!60} \\
\hline
\cellcolor{gray!60}& \cellcolor{gray!60} &\cellcolor{gray!60} &\cellcolor{gray!60} &\cellcolor{gray!60} & \cellcolor{gray!60} \\
\hline
g & & & & &  \\
\hline
z & & & & &  \\
\hline
d & & & & &  \\
\hline
b & & & & &  \\
\hline
p & & & & &  \\
\hline
\end{tabular}

\end{center}

\end{document}

• Don’t easily accept my answer! It does not solve the problem with the height of the cell. Feb 21, 2018 at 21:37

A bit more tweaking is needed from the original answer. I managed to get a nice result with the following:

\makeatletter
\def\highlight#1{%
\fboxrule2pt%
\hsize=\dimexpr\hsize+\fboxrule\relax
#1%
\@endpbox\unskip\setbox0\lastbox\bgroup
\fboxrule2pt%
\hspace*{-2\fboxsep}\fcolorbox{black}{white}{\box0}\hspace*{\dimexpr-2\fboxsep-\fboxrule\relax}}
\makeatother


However, I don’t know how to change the height of the box.

Edit: First approach to make the height equal to the regular cells. I managed to set the height of the fbox, but even if the fbox is lower than the cell box, the cell box will slightly increase in height.

\makeatletter
\newsavebox\saved@arstrutbox%
\global\setbox\saved@arstrutbox\copy\@arstrutbox%
\def\highlight#1{%
\fboxrule2pt%
\ht\@arstrutbox=\dimexpr\ht\saved@arstrutbox+\extrarowheight+2\fboxrule+2\arrayrulewidth\relax%
\dp\@arstrutbox=\dimexpr\dp\saved@arstrutbox\relax%
\hsize=\dimexpr\hsize+\fboxrule\relax%
#1%
\@endpbox\unskip\setbox0\lastbox\bgroup%
\fboxrule2pt%
\hspace*{-2\fboxsep}\fcolorbox{black}{white}{\box0}\hspace*{\dimexpr-2\fboxsep-\fboxrule\relax}}
\makeatother