尽管搜索了论坛,我仍然无法弄清楚如何控制内部单元格的左边距和右边距。在下面的示例中,我如何调整(例如减少)“L-text”单元格的左边距以及“R-text”单元格的右边距?请注意,需要定义列宽。谢谢,Jorge。
例子:
\documentclass[margin=3mm]{standalone}
\usepackage{array}
\usepackage{booktabs}
\aboverulesep=0ex
\belowrulesep=0ex
\newlength{\ColWidthNormal} \setlength{\ColWidthNormal}{1.50cm}
\newlength{\ColWidthRowHeader} \setlength{\ColWidthRowHeader}{1.50cm}
\newlength{\RuleOffsetLeft} \setlength{\RuleOffsetLeft}{-0.4pt}
\newlength{\RuleThicknessNormal} \setlength{\RuleThicknessNormal}{1.0pt}
\newcolumntype{C}{>{\centering\arraybackslash\leavevmode}p{\ColWidthNormal}}
\newcolumntype{R}{>{\raggedleft\arraybackslash}p{\ColWidthNormal}}
\newcolumntype{L}{>{\raggedright\arraybackslash}p{\ColWidthRowHeader}}
\begin{document}
\begin{tabular}{
|L|R|R|
}
\cmidrule[\RuleThicknessNormal](l{\RuleOffsetLeft}){2-3}
\multicolumn{1}{c|}{}& \multicolumn{1}{c|}{C-text}& \multicolumn{1}{c|}{C-text} \\
\midrule[\RuleThicknessNormal]
L-text& R-text& R-text \\
\midrule[\RuleThicknessNormal]
L-text& R-text& R-text \\
\midrule[\RuleThicknessNormal]
\end{tabular}
\end{document}
输出:
更新:解决方案\hspace
在最小列宽以下不起作用!有什么解决方法吗?
代码:
\documentclass[margin=3mm]{standalone}
\usepackage{array}
\usepackage{booktabs}
\aboverulesep=0ex
\belowrulesep=0ex
\newlength{\ColWidthNormal} \setlength{\ColWidthNormal}{1.50cm}
%\newlength{\ColWidthRowHeader} \setlength{\ColWidthRowHeader}{1.50cm}
\newlength{\ColWidthRowHeader} \setlength{\ColWidthRowHeader}{1.00cm}
\newlength{\RuleOffsetLeft} \setlength{\RuleOffsetLeft}{-0.4pt}
\newlength{\RuleThicknessNormal} \setlength{\RuleThicknessNormal}{1.0pt}
\newcolumntype{C}{>{\centering\arraybackslash\leavevmode}p{\ColWidthNormal}}
\newcolumntype{R}{>{\raggedleft\arraybackslash}p{\ColWidthNormal}}
\newcolumntype{L}{>{\raggedright\arraybackslash}p{\ColWidthRowHeader}}
\begin{document}
\setlength{\tabcolsep}{3pt}
\begin{tabular}{
|@{\hspace{0pt}}L|
R@{\hspace{-3pt}}|
R@{\hspace{-12pt}}|
}
\cmidrule[\RuleThicknessNormal](l{\RuleOffsetLeft}){2-3}
\multicolumn{1}{c|}{}& \multicolumn{1}{c|}{My C-text}& \multicolumn{1}{c|}{My C-text} \\
\midrule[\RuleThicknessNormal]
L-text& R-text& R-text \\
\midrule[\RuleThicknessNormal]
L-text& R-text& R-text \\
\midrule[\RuleThicknessNormal]
\end{tabular}
\end{document}
输出:
答案1
这是一个解决方案@{\hspace{some length}}
:
\documentclass[margin=3mm]{standalone}
\usepackage{array}
\usepackage{booktabs}
\aboverulesep=0ex
\belowrulesep=0ex
\newlength{\ColWidthNormal} \setlength{\ColWidthNormal}{1.50cm}
\newlength{\ColWidthRowHeader} \setlength{\ColWidthRowHeader}{1.50cm}
\newlength{\RuleOffsetLeft} \setlength{\RuleOffsetLeft}{-0.4pt}
\newlength{\RuleThicknessNormal} \setlength{\RuleThicknessNormal}{1.0pt}
\newcolumntype{C}{>{\centering\arraybackslash\leavevmode}p{\ColWidthNormal}}
\newcolumntype{R}{>{\raggedleft\arraybackslash}p{\ColWidthNormal}}
\newcolumntype{L}{>{\raggedright\arraybackslash}p{\ColWidthRowHeader}}
\begin{document}
\begin{tabular}{%
|@{\hspace{0pt}}L|R@{\hspace{1pt}}|R@{\hspace{2pt}}|
}
\cmidrule[\RuleThicknessNormal](l{\RuleOffsetLeft}){2-3}
\multicolumn{1}{c|}{}& \multicolumn{1}{c|}{C-text}& \multicolumn{1}{c|}{C-text} \\
\midrule[\RuleThicknessNormal]
L-text& R-text& R-text \\
\midrule[\RuleThicknessNormal]
L-text& R-text& R-text \\
\midrule[\RuleThicknessNormal]
\end{tabular}
\end{document}