![调整多列中的列](https://linux22.com/image/386042/%E8%B0%83%E6%95%B4%E5%A4%9A%E5%88%97%E4%B8%AD%E7%9A%84%E5%88%97.png)
我想将第一列改为三列,这样我可以在每行中写三个数字,而不是只写一个。其他一切都应保持不变。
\documentclass{article}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{showframe}
\newcommand{\thead}[1]{\begin{tabular}[t]{c}#1\end{tabular}}
\begin{document}
\begin{table}
\centering
\renewcommand{\tabularxcolumn}[1]{>{\centering\arraybackslash}p{#1}}
\begin{tabularx}{\textwidth}{|c|*4{X|}}
\hline
& \multicolumn{2}{c|}{\thead{here a longer text is written}}
& \multicolumn{2}{c|}{\thead{here also a longer text is written}} \\
\cline{2-5}
\thead{A\\number} & left & right & left & right \\
\hline
1 & X & X & X & X\\
2 & X & X & X & X\\
3 & X & X & X & X\\
4 & X & X & X & X\\
\hline
\end{tabularx}
\end{table}
\end{document}
答案1
\documentclass{article}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{showframe}
\newcommand{\thead}[1]{\begin{tabular}[t]{c}#1\end{tabular}}
\begin{document}
\begin{table}
\centering
\renewcommand{\tabularxcolumn}[1]{>{\centering\arraybackslash}p{#1}}
\begin{tabularx}{\textwidth}{|*{3}{c|}*{4}{X|}}
\hline
\multicolumn{3}{|c|}{}
&\multicolumn{2}{c|}{\thead{here a longer text\\ is written}}
& \multicolumn{2}{c|}{\thead{here also a longer\\ text is written}}
\\
\cline{4-7}
\multicolumn{3}{|c|}{\thead{3\\numbers}} &
left & right & left & right \\
\hline
1&11&21 & X & X & X & X\\
2&12&22 & X & X & X & X\\
3&13&23 & X & X & X & X\\
4&14&24 & X & X & X & X\\
\hline
\end{tabularx}
\end{table}
\end{document}