我正在使用此代码在 LaTeX 中创建表格:
\documentclass[11pt]{article}
\usepackage{threeparttable}
\usepackage{multirow}
\usepackage{makecell}
\usepackage{graphicx}
\usepackage{color, colortbl}
\usepackage{rotating}
\begin{document}
\begin{table}
\begin{threeparttable}
\begin{tabular}{c c | c c | c c c | c c c c}
% after \\: \hline or \cline{col1-col2} \cline{col3-col4} ...
&& \multicolumn{8}{c}{\textbf{PV}} & \\
& & F & N & & F & N & & F & N & \\
\noalign{\hrule height 0.7pt}
\parbox[t]{2mm}{\multirow{2}{*}{\rotatebox[origin=c]{90}{\textbf{AV}}}} & F & 8 & 9 & & 11 & 12 & & 150 & A & \parbox[t]{2mm}{\multirow{2}{*}{\rotatebox[origin=c]{270}{\scriptsize ABC}}}\\
& NF & 14 & 15 & & 17 & 18 & & A & A & \\
\noalign{\hrule height 0.7pt}
\parbox[t]{2mm}{\multirow{2}{*}{\rotatebox[origin=c]{90}{\textbf{AV}}}} & F & 8 & 9 & & 11 & 12 & & 15X & A & \parbox[t]{2mm}{\multirow{2}{*}{\rotatebox[origin=c]{270}{{\scriptsize dddd}}}}\\
& NF & 14 & 15 & & 17 & 18 & & A & A & \\
\noalign{\hrule height 0.7pt}
&& \multicolumn{2}{c}{\textbf{MSP}} && \multicolumn{2}{c}{\textbf{DBE}} && \multicolumn{2}{c}{\textbf{VDE}} \\
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}
输出如下:
multicolumn
我需要对和进行一些修改multirow
。我想从输出中删除红色框(红色框中的线),将黑色垂直线转换为红线(在中间),并在右侧有两个黑框(ABC 和 dddd 周围的黑框)。如何使用multicolumn
和进行此修改multirow
?
答案1
\documentclass[11pt]{article}
\usepackage{threeparttable}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{colortbl}
\begin{document}
\begin{table}
\begin{threeparttable}
\begin{tabular}{c c | c c | c c | c c| c|}
\multicolumn{2}{c}{}& \multicolumn{6}{c}{\textbf{PV}} &\multicolumn{1}{c}{} \\
\multicolumn{2}{c}{} & F &
\multicolumn{1}{c}{N} & F &
\multicolumn{1}{c}{N} & F &
\multicolumn{1}{c}{N} &\multicolumn{1}{c}{}\\
\hline
\multirow{2}{*}{\rotatebox[origin=c]{90}{\textbf{AV}}} & F & 8 & 9 & 11 & 12 & 150 & A & \parbox[t]{2mm}{\multirow{2}{*}{\rotatebox[origin=c]{270}{\scriptsize ABC}}}\\
& NF & 14 & 15 & 17 & 18 & A & A & \\
\hline
\multirow{2}{*}{\rotatebox[origin=c]{90}{\textbf{AV}}} & F & 8 & 9 & 11 & 12 & 15X & A & \parbox[t]{2mm}{\multirow{2}{*}{\rotatebox[origin=c]{270}{{\scriptsize dddd}}}}\\
& NF & 14 & 15 & 17 & 18 & A & A & \\
\hline
\multicolumn{2}{c}{}& \multicolumn{2}{c}{\textbf{MSP}} & \multicolumn{2}{c}{\textbf{DBE}} & \multicolumn{2}{c}{\textbf{VDE}} \\
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}
答案2
基于您初始代码的解决方案,带有所需的彩色垂直线。我添加了标题和表格之间的正确垂直间距。由于技术原因,caption
我不得不使用:\hhline
\documentclass[11pt]{article}
\usepackage{threeparttable}
\usepackage{multirow}
\usepackage{makecell, hhline}
\usepackage{graphicx}
\usepackage{xcolor, colortbl}
\usepackage{textcomp}
\usepackage{rotating}
\usepackage{caption}
\begin{document}
\begin{table}
\centering\setlength\arrayrulewidth{0.7pt}
\caption{MM}
\begin{threeparttable}
\begin{tabular}{c c | c c !{\color{red}\vrule width0.7pt}c c !{\color{red}\vrule width0.7pt} c c c}
\multicolumn{9}{c}{\textbf{PV}} \\
\multicolumn{2}{c}{}& F & \multicolumn{1}{c}{N} & F & \multicolumn{1}{c}{N} & F & N & \\
\hhline{~-------~}
\parbox[t]{2mm}{\multirow{2}{*}{\rotatebox[origin=c]{90}{\textbf{AV}}}} & F & \cellcolor{gray!12}{8} & 9 & \cellcolor{gray!12}{11} & 12 & \cellcolor{gray!12}{150} & A & \parbox[t]{2mm}{\multirow{2}{*}{\rotatebox[origin=c]{270}{\scriptsize ABC}}}\\
& NF & 14 & \cellcolor{gray!12}{15} & 17 & \cellcolor{gray!12}{18} & A & \cellcolor{gray!12}{A} & \\
\hhline{~-------~}
\parbox[t]{2mm}{\multirow{2}{*}{\rotatebox[origin=c]{90}{\textbf{AV}}}} & F & \cellcolor{gray!12}{8} & 9 & \cellcolor{gray!12}{11} & 12 & \cellcolor{gray!12}{15X} & A & \parbox[t]{2mm}{\multirow{2}{*}{\rotatebox[origin=c]{270}{{\scriptsize dddd}}}}\\
& NF & 14 & \cellcolor{gray!12}{15} & 17 & \cellcolor{gray!12}{18} & A & \cellcolor{gray!12}{A} & \\
\cline{2-8}
\multicolumn{2}{c}{}& \multicolumn{2}{c}{\textbf{MSP}} & \multicolumn{2}{c}{\textbf{DBE}} & \multicolumn{2}{c}{\textbf{VDE}} \\
\end{tabular}
\begin{tablenotes}
\footnotesize
\item[\textdagger]BBBddddd
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}