# Partial cline in table only for some fraction

Example:

\begin{tabular}{|c|c|}
\hline
1 & 2 \\
\cline{1-1}\cline{2-2}
3 & 4 \\
\hline
\end{tabular}


I want cline to cover only e.g. half of a cell of a table. Or maybe I can specify an offset when the line should start (e.g. to skip the first cm).

Is this easily possible?

(One workaround could be to introduce another column, and then use multicolumn everywhere. But this would be somewhat annoying. Also not sure how I could control the width of the columns then. This might be related.)

(This looks very related. I did not found this via Google. Maybe this can be marked as duplicate. Although the solution doesn't quite work for me (I get some errors), and I don't really understand it. I thought it is still valuable to post for other people who would use my Google search terms, to find this.)

• Please provide a minimum working example. Both because it is the protocol for this site and because it will help explain the particulars of your use case (for which alternative approaches might apply). – Steven B. Segletes May 3 at 14:43
• If I understand your question correctly, then it is duplicate to tex.stackexchange.com/questions/298300/… – Zarko May 3 at 15:05

It's easy with tikz and nicematrix.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{nicematrix}
\begin{document}
\begin{NiceTabular}{cc}[cell-space-top-limit=4pt]
1 & 2 \\
3 & 4 \\
\CodeAfter
\tikz\draw (3 -| 1) rectangle (1 -| 3);
\tikz\draw (1 -| 2) -- (3 -| 2);
\tikz\draw[red] ($(2 -| 1)!0.5!(2 -| 2)$) -- (2 -| 3);
\end{NiceTabular}
\end{document}


• Interesting. But then I need to change by tabular to NiceTabular. I don't really know this environment. I use many features of tabular, like siunitx, multirow, multicolumn, cline, hline. Do they all work in the same way? I would prefer to not use some completely different syntax just to have one cline in one place slightly different. – Albert May 3 at 20:06

I found one solution (adapted from here):

\makeatletter
\def\cpartlineleft#1{\@cpartlineleft#1\@nil}
\def\@cpartlineleft#1,#2\@nil{%
\omit
\@multicnt#1%
\ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
\@multicnt#1%
\kern#2
\cr
\noalign{\vskip-\arrayrulewidth}}
\makeatother


Then I can use it as:

\begin{tabular}{|c|c|}
\hline
1 & 2 \\
\cpartlineleft{1,1em}\cline{2-2}
3 & 4 \\
\hline
\end{tabular}