有没有办法对包装\cdashline
中的左或右进行修剪arydshln
,类似于\cmidrule(lr)
?
梅威瑟:
\documentclass{article}
\usepackage{booktabs}
\usepackage{arydshln}
\setlength\dashlinedash{0.5pt}
\setlength\dashlinegap{1.5pt}
\newcommand{\cdotline}[1]{\noalign{\vskip\abovetopsep}\cdashline{#1}\noalign{\vskip\belowrulesep}}
\begin{document}
\begin{table}
\begin{tabular}{@{}rrr@{}}
\cdotline{2-3}
Test & Test & Test \\
\cmidrule(l){2-3}
\end{tabular}
\end{table}
\end{document}
答案1
这是一个\cdashedline
插入的命令修剪虚线。语法是的语法\cline
。它应该与兼容longtable
。
booktabs
我还没有对与和完全相似的行为进行调整,arydshln
但如果愿意的话,这很容易做到。
\documentclass{article}
\usepackage{array}
\usepackage{xparse}
\usepackage{longtable}
\ExplSyntaxOn
\NewExpandableDocumentCommand { \cdashedline } { }
{
\noalign { \skip_vertical:n { 3 mm } }
\__johan_cline_i:nn 1
}
\cs_set:Npn \__johan_cline_i:nn #1 #2 { \__johan_cline_i:w #1-#2 \q_stop }
\cs_set:Npn \__johan_cline_i:w #1-#2-#3 \q_stop
{
\int_compare:nNnT { #1 } < { #2 }
{ \multispan { \int_eval:n { #2 - #1 } } & }
\multispan { \int_eval:n { #3 - #2 + 1 } }
{
\skip_horizontal:N \tabcolsep
\xleaders
\hbox
{
\vrule height 0.4pt depth 0pt width 2pt
\kern 1pt
}
\hfill
\vrule height 0.4pt depth 0pt width 2pt
\skip_horizontal:N \tabcolsep
}
\peek_meaning_remove_ignore_spaces:NTF \cdashedline
{ & \exp_args:Ne \__johan_cline_i:nn { \int_eval:n { #3 + 1 } } }
{
\everycr { } \cr
\noalign { \skip_vertical:n { 3 mm } }
}
}
\ExplSyntaxOff
\begin{document}
\begin{longtable}{cccc}
text & text & other text & more text \\
text & text & other text & more text \\
text & text & other text & more text \\
\cdashedline{2-3} \cdashedline{4-4}
text & text & other text & more text \\
text & text & other text & more text \\
\end{longtable}
\end{document}
答案2
在(2020-05-08 ≥ 4.0){NiceTabular}
中,您可以使用表格下nicematrix
创建的 PGF/Tikz 节点用 Tikz 绘制您想要的任何规则。nicematrix
\documentclass{article}
\usepackage{booktabs}
\usepackage{nicematrix}
\usepackage{tikz}
\begin{document}
\begin{NiceTabular}{rrr}
Test & Test & Test \\
Test & Test & Test \\
\cmidrule(l){2-3}
\CodeAfter
\tikz [dotted , shorten < = \cmidrulekern]
\draw [shorten < = \cmidrulekern] (2-|2) -- (2-|4) ;
\end{NiceTabular}
\end{document}