@ {\ hskip} và \ đa cột
Xem xét bảng sau
\begin{tabular}{cccccc}
\toprule
N & \multicolumn3c{L-family} & \multicolumn2c{H-family} \\
n & large & Large & LARGE & huge & Huge \\
\bottomrule
\end{tabular}
Tôi muốn nhấn mạnh việc nhóm các cột, do đó, @ -construction
\def\htc#1{ {\hskip#1\tabcolsep} }
\begin{tabular}{c @\htc4 ccc @\htc4 cc}
\toprule
N & \multicolumn3c{L-family} & \multicolumn2c{H-family} \\
n & large & Large & LARGE & huge & Huge \\
\bottomrule
\end{tabular}
Bây giờ tôi phải tinh chỉnh đa cột vì không gian ngang bị tắt
\begin{tabular}{c @\htc4 ccc @\htc4 cc}
\toprule
N & \multicolumn3{@\htc{-3}c}{L-family} & \multicolumn2{@\htc0c}{H-family}
\\
n & large & Large & LARGE & huge & Huge
\\
\bottomrule
\end{tabular}
Tại sao các hằng số bẩn? Nó có thể được thực hiện theo cách tự động hơn không?
MWE
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\parskip1em
Consider the following table
\begin{tabular}{cccccc}
\toprule
N & \multicolumn3c{L-family} & \multicolumn2c{H-family} \\
n & large & Large & LARGE & huge & Huge \\
\bottomrule
\end{tabular}
~
I want to emphasis the grouping of columns, hence the @-construction
\def\htc#1{ {\hskip#1\tabcolsep} }
\begin{tabular}{c @\htc4 ccc @\htc4 cc}
\toprule
N & \multicolumn3c{L-family} & \multicolumn2c{H-family} \\
n & large & Large & LARGE & huge & Huge \\
\bottomrule
\end{tabular}
~
Now I have to fine-tune the multicolumn
\begin{tabular}{c @\htc4 ccc @\htc4 cc}
\toprule
N & \multicolumn3{@\htc{-3}c}{L-family} & \multicolumn2{@\htc0c}{H-family}
\\
n & large & Large & LARGE & huge & Huge
\\
\bottomrule
\end{tabular}
Why the dirty constantss?
\end{document}
Tái bút Trong câu hỏi này: Vấn đề với căn chỉnh khi sử dụng nhiều cột và @ {\ hskip}? , Câu trả lời gợi ý để ngăn chặn \tabcolsepbằng cách sử dụng trống @{}. Có thể thấy rằng điều này không phải lúc nào cũng mang lại cho bạn kết quả mong muốn.
Trả lời
Các @biểu thức là một phần của cạnh bên phải của cột có liên quan, vì vậy khi sử dụng, \multicolumnhãy lặp lại thành phần đầy đủ cho khoảng bao gồm cả @biểu thức bên phải của nó :
\documentclass{article}
\usepackage{booktabs}
\def\htc#1{ {\hskip#1\tabcolsep} }
\begin{document}
\parskip1em
I want to emphasis the grouping of columns, hence the @-construction
\begin{tabular}{c @{\htc4} ccc @{\htc4} cc}
\toprule
N & \multicolumn{3}{c@{\htc4}}{L-family} & \multicolumn{2}{c}{H-family} \\
n & large & Large & LARGE & huge & Huge \\
\bottomrule
\end{tabular}
\end{document}