1

I am trying to make a table with certain cells emphasized with a thickened border around those cells. My attempt with \arrayrulewidth was quite successful, except that the \cline thickened this way doesn't always align well with the standard ones, as could be seen from this example: enter image description here as could be seen, the thickened border stick out of the bottom.

Is there any suggestion to improve this?

The code producing the example is

\documentclass[border=10pt,11pt]{standalone}

\usepackage{setspace}
\usepackage{array,booktabs,multirow,makecell}
\newlength{\Oldarrayrulewidth}
\newcommand{\Cline}[2]{%
  \noalign{\global\setlength{\Oldarrayrulewidth}{\arrayrulewidth}}%
  \noalign{\global\setlength{\arrayrulewidth}{#1}}\cline{#2}%
  \noalign{\global\setlength{\arrayrulewidth}{\Oldarrayrulewidth}}}

%%% Japanese support
\usepackage{xeCJK}
\usepackage{zxjatype}
\usepackage{fontspec}
\def\cjkfontscale{1.0}
\setmainfont{Kozuka Mincho Pr6N}
\setCJKmainfont[Scale=\cjkfontscale]{Kozuka Mincho Pr6N}
\setCJKsansfont[Scale=\cjkfontscale]{Kozuka Gothic Pr6N}
\setCJKmonofont[Scale=\cjkfontscale]{Kozuka Gothic Pr6N}
\newCJKfontfamily\boldmincho{Hiragino Mincho ProN W6}

\begin{document}

\def\heavyrulewidth{2pt}
\def\strongvline{\vline width \heavyrulewidth}
\def\arraystretch{2.0}
\def\padcaption#1{\hspace{1.6em}#1\hspace{1.6em}}
\begin{tabular}{|c|r|c|r|}
  \cline{1-4}
  \multicolumn{1}{|c|}{\raisebox{-8pt}{\padcaption{件名}}}
  & \multicolumn{1}{|l|}{\parbox[t][3em]{12em}{Subject}}
  & \multirow{2}{*}[-10.8pt]{\hspace{1em}{納品先}\hspace{1em}}
  & \multirow{2}{*}{\parbox[t][4em]{14em}{Address}} \\
  \Cline{\heavyrulewidth}{1-2}
  \multicolumn{1}{!{\strongvline}c|}{\hspace{-1.5em}\padcaption{納品日}}
  & \multicolumn{1}{|r!{\strongvline}}{\boldmincho\Large 2020/1/1}
  & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} \\
  \Cline{\heavyrulewidth}{1-2}\cline{3-4}
\end{tabular}
\def\arraystretch{1.0}
\vspace{1em}

\end{document}

(using XeLaTeX. Japanese handling part is non-essential to this question but included to better demonstrate the original usage.)

0

2 Answers 2

1

With the latest version of nicematrix (v. 5.19 of 2021-07-23), it's easy to draw the required frame inside the rectangle with one line of code.

\documentclass[border=10pt,11pt]{standalone}

\usepackage{setspace}
\usepackage{array,booktabs,multirow,makecell}

\usepackage{nicematrix}
\usepackage{tikz}


%%% Japanese support
\usepackage{xeCJK}
\usepackage{zxjatype}
\usepackage{fontspec}
\def\cjkfontscale{1.0}
\setmainfont{Kozuka Mincho Pr6N}
\setCJKmainfont[Scale=\cjkfontscale]{Kozuka Mincho Pr6N}
\setCJKsansfont[Scale=\cjkfontscale]{Kozuka Gothic Pr6N}
\setCJKmonofont[Scale=\cjkfontscale]{Kozuka Gothic Pr6N}


\begin{document}

\def\heavyrulewidth{2pt}
\def\strongvline{\vline width \heavyrulewidth}
\def\arraystretch{2.0}
\def\padcaption#1{\hspace{1.6em}#1\hspace{1.6em}}
\begin{NiceTabular}{|c|r|c|r|}% [hvlines]
\hline
  \raisebox{-8pt}{\padcaption{件名}}
  & \multicolumn{1}{l}{\parbox[t][3em]{12em}{Subject}}
  & \multirow{2}{*}[-10.8pt]{\hspace{1em}{納品先}\hspace{1em}}
  & \multirow{2}{*}{\parbox[t][4em]{14em}{Address}} \\
  \Block[tikz=clip,tikz={draw,line width=4pt},hvlines]{1-2}{}
  \hspace{-1.5em}\padcaption{納品日}
  & \Large 2020/1/1 \\
\hline
\end{NiceTabular}
\def\arraystretch{1.0}
\vspace{1em}

\end{document}

The line is : \Block[tikz=clip,tikz={draw,line width=4pt},hvlines]{1-2}{}

  • The block has one row and two columns (1-2).
  • With tikz=clip, the rectangle corresponding to the block is used to clip further constructions.
  • With tikz={draw,line width=4pt}, a frame is drawn with a thikness equal to 4 pt. However, with the clipping, only the interior part of that frame will appear (with a thickness equal to 2 pt).
  • The key hvlines is used to draw all the rules inside the block (in fact, only one: the central vertical one).

Output of the above code

3

Here is a solution with {NiceTabular} of nicematrix. This environment is constructed upon {tabular} but adds PGF/Tikz nodes under the cells, row and columns. It's easy to use these nodes to draw with Tikz whatever rule you want.

\documentclass[border=10pt,11pt]{standalone}

\usepackage{setspace}
\usepackage{array,booktabs,multirow,makecell}

\usepackage{nicematrix}
\usepackage{tikz}


%%% Japanese support
\usepackage{xeCJK}
\usepackage{zxjatype}
\usepackage{fontspec}
\def\cjkfontscale{1.0}
\setmainfont{Kozuka Mincho Pr6N}
\setCJKmainfont[Scale=\cjkfontscale]{Kozuka Mincho Pr6N}
\setCJKsansfont[Scale=\cjkfontscale]{Kozuka Gothic Pr6N}
\setCJKmonofont[Scale=\cjkfontscale]{Kozuka Gothic Pr6N}
% \newCJKfontfamily\boldmincho{Hiragino Mincho ProN W6}

\begin{document}

\def\heavyrulewidth{2pt}
\def\strongvline{\vline width \heavyrulewidth}
\def\arraystretch{2.0}
\def\padcaption#1{\hspace{1.6em}#1\hspace{1.6em}}
\begin{NiceTabular}{|c|r|c|r|}
\hline
  \raisebox{-8pt}{\padcaption{件名}}
  & \multicolumn{1}{l}{\parbox[t][3em]{12em}{Subject}}
  & \multirow{2}{*}[-10.8pt]{\hspace{1em}{納品先}\hspace{1em}}
  & \multirow{2}{*}{\parbox[t][4em]{14em}{Address}} \\
  \hspace{-1.5em}\padcaption{納品日}
  & \Large 2020/1/1 \\
\CodeAfter
\begin{tikzpicture}
\draw (3-|1) -- (3-|5) ;
\draw [very thick] (2-|1) rectangle (3-|3) ;
\end{tikzpicture}
\end{NiceTabular}
\def\arraystretch{1.0}
\vspace{1em}

\end{document}

Ouput of the above code

1

You must log in to answer this question.

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