我想要得到 的等效虚线版本\cmidule(lr){1-2}
。看来解决方案并不简单。
您想到的最简单的方法是什么?
答案1
下面实现了一种新的“绘制类型”,相当于(某种程度上)\cdashlinelr
常规\cmidrule(lr)
垂直间距:
\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}
答案2
以下是您可以使用 做的{NiceTabular}
事情nicematrix
。
{tabular}
该环境与经典环境(的)类似,array
但在单元格、行和列下创建了 PGF/Tiks 节点。
构建数组后,可以使用这些节点在 Tikz 中绘制您想要的任何规则。
\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}