答案1
我认为 8 个可见数据列应具有相同的宽度,并且最后一行的列分隔线应位于前几行列分隔线的中间。如果是这样,以下解决方案可能会引起您的兴趣。
\documentclass{article}
\usepackage{array} % for 'w' column type and '\extrarowheight' macro
\usepackage{amsmath} % for '\dfrac' macro
\usepackage{calc} % help perform calculations on the fly
\newlength\mylen
\setlength\mylen{\tabcolsep} % or some other length
\renewcommand\sb[1]{\textsubscript{#1}} % handy shortcut macro
\newcommand\mc[1]{% handy shortcut macro
\multicolumn{2}{wc{2\mylen+2\tabcolsep}|}{#1}}
\begin{document}
\begin{table}[ht]
\setlength{\extrarowheight}{2pt} % for a more open "look"
\begin{tabular}{| l | *{16}{wc{\mylen}} | }
% 8 or 7 visible data columns, but 16 underlying, "structural" columns
\hline
Notes & \mc{C\sb{4}} & \mc{D\sb{4}} & \mc{E\sb{4}} & \mc{F\sb{4}}
& \mc{G\sb{4}} & \mc{A\sb{4}} & \mc{B\sb{4}} & \mc{C\sb{5}} \\
\hline
Frequency based on C\sb{4} &
\mc{1} & \mc{$\dfrac{9^{\mathstrut}}{8_{\mathstrut}}$} &
\mc{$\dfrac{5}{4}$} & \mc{} & \mc{} & \mc{} & \mc{} & \mc{2} \\
\hline
Number of cents above C\sb{4} &
\mc{0} & \mc{204} & \mc{386} & \mc{} &
\mc{} & \mc{} & \mc{} & \mc{1200} \\
\hline
Intervals between &
\multicolumn{3}{wc{3\mylen+4\tabcolsep+1\arrayrulewidth}|}{204} &
\mc{182} & \mc{112} & \mc{204} &
\mc{182} & \mc{204} &
\multicolumn{3}{c|}{112} \\
adjacent notes, in cents &
\multicolumn{3}{c|}{M} &
\mc{m} & \mc{s} & \mc{M} & \mc{m} & \mc{M} &
\multicolumn{3}{c|}{s} \\
\hline
\end{tabular}
\end{table}
\end{document}
答案2
只需拥有足够的列来捕获所有单元格边界,然后根据需要跨越:
\documentclass{article}
\begin{document}
\newcommand\mm[1]{\multicolumn{2}{c|}{#1}}
\begin{tabular}{l|*{8}{c}}
aaaa & \mm{1} & \mm{2} & \mm{3} & \mm{4} \\
\hline
bbbb & \multicolumn{3}{c|}{xxx} &\mm{yyy} & \multicolumn{3}{c|}{zzz}
\end{tabular}
\end{document}
这是使用的c
,所以列宽取决于内容,如果您想要固定宽度,您可以使用p{..}
或(数组包)wc{..}
答案3
\documentclass{article}
\usepackage{geometry}
\usepackage{array}
\usepackage{makecell}
\begin{document}
\begin{center}
\renewcommand{\arraystretch}{1.5}
\renewcommand{\v}{\hfill\vline\hfill}
\begin{tabular}{|l|*{8}{w{c}{1cm}|}}
\hline
Notes & C$_4$ & D$_4$ & E$_4$ & F$_4$ & G$_4$ & A$_4$ & B$_4$ & C$_5$ \\
\hline
Frequency based on C$_4$& $1$ & $\frac{9}{8}$ & $\frac{5}{4}$ & $\frac{4}{3}$ & $\frac{3}{2}$ &
$\frac{5}{3}$ & $\frac{15}{8}$ & $2$ \\
\hline
Number of cents above C$_4$& 0 & 204 & 386 & 498 & 702 & 884 & 1088 & 1200 \\
\hline
\makecell[l]{Intervals between\\ adjacent notes in cents}&
\multicolumn{8}{c|}{ \hspace*{6mm}%
\makecell{204\\M}\v \makecell{182\\m}\v
\makecell{112\\s}\v \makecell{204\\M}\v
\makecell{182\\m}\v \makecell{204\\M}\v
\makecell{112\\s}\hspace*{6mm}%
} \\
\hline
\end{tabular}
\end{center}
\end{document}