% !tex xelatex
\documentclass[a4paper]{ctexart}
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\usepackage{array}
\usepackage{multirow}
\usepackage{colortbl} % 必须包含的包
\usepackage{xcolor}
\usepackage{graphicx}
\definecolor{lightblue}{rgb}{0.85,0.95,1}
\definecolor{lightyellow}{rgb}{1,1,0.85}
\begin{document}
\pagestyle{empty}
\centering
{\LARGE\bfseries 九九乘法口诀表}\\[1cm]
% 主乘法表
\begin{minipage}{0.9\textwidth}
\centering
\setlength{\tabcolsep}{3mm} % 列间距
\renewcommand{\arraystretch}{1.5} % 行高
\begin{tabular}{|>{\columncolor{lightblue}}c|*{9}{>{\centering\arraybackslash}m{1.2cm}|}}
\hline
\rowcolor{lightyellow}
\multirow{2}{*}{\textcolor{red}{乘数}} &
\multicolumn{9}{c|}{\textcolor{red}{被乘数}} \\
\cline{2-10}
\rowcolor{lightblue}
\cellcolor{lightyellow}& 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
\hline
1 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
\hline
2 & 2 & 4 & 6 & 8 & 10 & 12 & 14 & 16 & 18 \\
\hline
3 & 3 & 6 & 9 & 12 & 15 & 18 & 21 & 24 & 27 \\
\hline
4 & 4 & 8 & 12 & 16 & 20 & 24 & 28 & 32 & 36 \\
\hline
5 & 5 & 10 & 15 & 20 & 25 & 30 & 35 & 40 & 45 \\
\hline
6 & 6 & 12 & 18 & 24 & 30 & 36 & 42 & 48 & 54 \\
\hline
7 & 7 & 14 & 21 & 28 & 35 & 42 & 49 & 56 & 63 \\
\hline
8 & 8 & 16 & 24 & 32 & 40 & 48 & 56 & 64 & 72 \\
\hline
9 & 9 & 18 & 27 & 36 & 45 & 54 & 63 & 72 & 81 \\
\hline
\end{tabular}
\end{minipage}
\end{document}
我上面的表格第一列的第一个cell垮了两行,但是编译后只能显示第一行内容,cell里第二行的内容无法显示,请教大神帮忙指导一下。
其实非常简单,只要把合并单元格挪到下面一格就行了,\multirow
支持反向合并
% !tex xelatex
\documentclass[a4paper]{ctexart}
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\usepackage{array}
\usepackage{multirow}
\usepackage{colortbl} % 必须包含的包
\usepackage{xcolor}
\usepackage{graphicx}
\definecolor{lightblue}{rgb}{0.85,0.95,1}
\definecolor{lightyellow}{rgb}{1,1,0.85}
\begin{document}
\pagestyle{empty}
\centering
{\LARGE\bfseries 九九乘法口诀表}\\[1cm]
% 主乘法表
\begin{minipage}{0.9\textwidth}
\centering
\setlength{\tabcolsep}{3mm} % 列间距
\renewcommand{\arraystretch}{1.5} % 行高
\begin{tabular}{|>{\columncolor{lightblue}}c|*{9}{>{\centering\arraybackslash}m{1.2cm}|}}
\hline
\rowcolor{lightyellow}
&
\multicolumn{9}{c|}{\textcolor{red}{被乘数}} \\
\cline{2-10}
\rowcolor{lightblue}
\cellcolor{lightyellow}
\multirow{-2}{*}{\textcolor{red}{乘数}}
& 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
\hline
1 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
\hline
2 & 2 & 4 & 6 & 8 & 10 & 12 & 14 & 16 & 18 \\
\hline
3 & 3 & 6 & 9 & 12 & 15 & 18 & 21 & 24 & 27 \\
\hline
4 & 4 & 8 & 12 & 16 & 20 & 24 & 28 & 32 & 36 \\
\hline
5 & 5 & 10 & 15 & 20 & 25 & 30 & 35 & 40 & 45 \\
\hline
6 & 6 & 12 & 18 & 24 & 30 & 36 & 42 & 48 & 54 \\
\hline
7 & 7 & 14 & 21 & 28 & 35 & 42 & 49 & 56 & 63 \\
\hline
8 & 8 & 16 & 24 & 32 & 40 & 48 & 56 & 64 & 72 \\
\hline
9 & 9 & 18 & 27 & 36 & 45 & 54 & 63 & 72 & 81 \\
\hline
\end{tabular}
\end{minipage}
\end{document}
另外,这个需求显然有基于循环的方案,可参考这个链接。