我想使用某种变量来定义表格标尺的参数,这样只需更改变量定义,我就可以调整标尺,而无需进一步更改表格代码。例如,在下面的例子中,我想在注释中指出的地方使用变量来表示数量。我该如何做到这一点?谢谢,Jorge。
例子:
\documentclass[margin=3mm]{standalone}
\usepackage{array}
\usepackage{booktabs}
\aboverulesep=0ex
\belowrulesep=0ex
\begin{document}
\begin{tabular}{|c|c|c|}
\cmidrule[1.0pt](l{-0.4pt}){2-3} % <- would like to parametrize 1.0pt and -0.4pt
\multicolumn{1}{c|}{}& Text& Text \\
\cmidrule[2.0pt]{1-3} % <- would like to parametrize 2.0pt
Text& Text& Text \\
\cmidrule[3.0pt]{1-3} % <- would like to parametrize 3.0pt
Text& Text& Text \\
\midrule[4.0pt] % <- would like to parametrize 4.0pt
\end{tabular}
\end{document}
输出:
答案1
谢谢 nox;这确实有效!:
\documentclass[margin=3mm]{standalone}
\usepackage{array}
\usepackage{booktabs}
\aboverulesep=0ex
\belowrulesep=0ex
\newlength{\RuleOffsetLeft} \setlength{\RuleOffsetLeft}{-0.4pt}
\newlength{\RuleThicknessNormal} \setlength{\RuleThicknessNormal}{1.0pt}
\newlength{\RuleThicknessThick} \setlength{\RuleThicknessThick}{2.0pt}
\newlength{\RuleThicknessVeryThick} \setlength{\RuleThicknessVeryThick}{3.0pt}
\newlength{\RuleThicknessExtremelyThick} \setlength{\RuleThicknessExtremelyThick}{4.0pt}
\begin{document}
\begin{tabular}{|c|c|c|}
\cmidrule[\RuleThicknessNormal](l{\RuleOffsetLeft}){2-3}
\multicolumn{1}{c|}{}& Text& Text \\
\cmidrule[\RuleThicknessThick]{1-3}
Text& Text& Text \\
\cmidrule[\RuleThicknessVeryThick]{1-3}
Text& Text& Text \\
\midrule[\RuleThicknessExtremelyThick]
\end{tabular}
\end{document}