I want to get the equivalent dashed version of \cmidule(lr){1-2}. Looks like the solution is not trivial.
What is the easiest way you think of?
I want to get the equivalent dashed version of \cmidule(lr){1-2}. Looks like the solution is not trivial.
What is the easiest way you think of?
The following implements a new "draw type", equating (somewhat) \cdashlinelr to \cmidrule(lr) the regular vertical spacing:
\documentclass{article}
\usepackage{booktabs,arydshln}
\makeatletter
\def\adl@drawiv#1#2#3{%
\hskip.5\tabcolsep
\xleaders#3{#2.5\@tempdimb #1{1}#2.5\@tempdimb}%
#2\z@ plus1fil minus1fil\relax
\hskip.5\tabcolsep}
\newcommand{\cdashlinelr}[1]{%
\noalign{\vskip\aboverulesep
\global\let\@dashdrawstore\adl@draw
\global\let\adl@draw\adl@drawiv}
\cdashline{#1}
\noalign{\global\let\adl@draw\@dashdrawstore
\vskip\belowrulesep}}
\makeatother
\begin{document}
\begin{tabular}{lll}
\toprule
This is a & nice table & with three columns \\
\cmidrule(lr){2-3}
Some & row content & in the second row \\
\bottomrule
\end{tabular}
\begin{tabular}{lll}
\toprule
This is a & nice table & with three columns \\
\cdashlinelr{2-3}
Some & row content & in the second row \\
\bottomrule
\end{tabular}
\end{document}
\begin{tabular}{lll} \toprule This is a & nice table & with three columns \\ \cdashlinelr{1-1} \cdashlinelr{2-2} \cdashlinelr{3-3} Some & row content & in the second row \\ \bottomrule \end{tabular}
– tales
Apr 26 '19 at 16:55
\dashlinedash (to change the dashed line length) and \dashlinegap (to change the gap length). Defaults for both are 4.0pt. Try, for example, with \setlength{\dashlinedash}{2\dashlinedash}.
– Werner
Oct 06 '20 at 18:57
Here is what you can do with {NiceTabular} of nicematrix.
That environment is similar to the classical environment {tabular} (of array) but creates PGF/Tiks nodes under the cells, rows and columns.
It's possible to use those nodes to draw whatever rule you want with Tikz after the construction of the array.
\documentclass{article}
\usepackage{nicematrix,tikz}
\usepackage{booktabs}
\begin{document}
\begin{NiceTabular}{lll}
\toprule
This is a & nice table & with three columns \
Some & row content & in the second row \
\bottomrule
\CodeAfter
\tikz \draw [dashed, shorten < = 4pt, shorten > = 4pt] (2-|2) -- (2-|4) ;
\end{NiceTabular}
\end{document}