答案1
像这样吗?
\documentclass{article}
\usepackage{array}
\newcommand{\tabsymbol}[1]{%
\multicolumn{1}{c@{\makebox[0pt]{#1}}}{}%
}
\newcolumntype{C}{>{\centering\arraybackslash}p{.8cm}}
\begin{document}
\begin{tabular}{C|C|C|C|C|}
\tabsymbol{0}&\tabsymbol{1}&\tabsymbol{2}&\tabsymbol{3}&\tabsymbol{4}\\
& A & B & C & D \\ \hline
& & & & \\ \hline
& & & & \\ \hline
& & & & \\ \hline
\end{tabular}
\end{document}
答案2
这里我使用来\readTABstack
分析中的数据,tabular
以便提取和利用列宽。
\documentclass{article}
\usepackage{tabstackengine}
\begin{document}
\def\data{
This & is & a & test & of & something\\
\hline%
&and¬&easy&at&that\\
\hline
}
\setstackEOL{\\
\hline}% MUST MIMIC the \\ \hline format of \data
\expandafter\readTABstack\expandafter{\data&&&&&}% ENOUGH & ADDED FOR TOTAL COLUMNS
\newcommand\skipcolumn[2]{%
\unskip\hspace{\dimexpr2\tabcolsep+\TABwd{#1}}\makebox[0pt]{#2}\ignorespaces}
\stackunder{%
\skipcolumn{1}{A}\skipcolumn{2}{B}\skipcolumn{3}{C}
\skipcolumn{4}{D}\skipcolumn{5}{E}\skipcolumn{6}{F}
}{%
\begin{tabular}{|c|c|c|c|c|c|}
\data
\end{tabular}%
}
\end{document}
为了从逻辑角度理解发生了什么,我必须构建一个与 具有相同列尺寸的 TABstack tabular
。如果我能做到这一点,tabstackengine
就会记住原始数据的列尺寸,\TABwd
稍后可以通过上述方法使用。下面,我展示了数据的等效 TABstack 构建tabular
。
\documentclass{article}
\usepackage{tabstackengine}
\begin{document}
\def\data{
This & is & a & test & of & something\\\hline
&and¬&easy&at&that\\\hline
}
\begin{tabular}{|c|c|c|c|c|c|}
\data
\end{tabular}
is a tabular
\setstacktabbedgap{2\tabcolsep}
\setstackEOL{\\\hline}
\rule[-3ex]{\fboxrule}{4ex}%
\hspace{\dimexpr\tabcolsep-\fboxrule}%
\expandafter\tabbedLongunderstack\expandafter{\data&&&&&}%
\hspace{\dimexpr\tabcolsep-\fboxrule}%
\rule[-3ex]{\fboxrule}{4ex}
is a TABstack
\end{document}