表格中的垂直文本没有垂直线

表格中的垂直文本没有垂直线

我想通过以下方式修改此表: 在此处输入图片描述

这是我的 MWE,我尝试过但没有成功。

\documentclass{article}
\usepackage{array}    % \extrarowheight macro
\usepackage{graphicx} % \rotatebox macro
\usepackage{multirow} % \multirow macro
\usepackage{booktabs} % for \toprule, \midrule, \bottomrule
\begin{document}


%Before

\noindent\makebox[\textwidth][c]{
\begin{minipage}[c]{\textwidth}
\centering
\begin{tabular}{@{}ccccc@{}}
\toprule
Expert & \multicolumn{4}{c@{}}{Prediction}\\
\cmidrule(l){2-5}
& Blah & BlahBlahBlahBlah & BlahBlahBlah & BlahBlahBlah \\
\midrule
Blah & $10$ & $10$ & $10$ & $10$\\ 
BlahBlahBlahBlah & $10$ & $10$ & $10$ & $10$\\ 
BlahBlahBlah & $10$ & $10$ & $10$ & $10$\\ 
BlahBlahBlah & $10$ & $10$ & $10$ & $10$\\ 
\bottomrule
\end{tabular}
\end{minipage}
}

\vspace{5cm}

%After
\noindent\makebox[\textwidth][c]{
\begin{minipage}[c]{\textwidth}
\centering
\begin{tabular}{c|@{}ccccc@{}}
\toprule
\parbox[t]{2mm}{\multirow{4}{*}{\rotatebox[origin=c]{90}{Expert}}} &  & \multicolumn{4}{c@{}}{Prediction}\\
\cmidrule(l){2-5}
& Blah & BlahBlahBlahBlah & BlahBlahBlah & BlahBlahBlah \\
\midrule
Blah & $10$ & $10$ & $10$ & $10$\\ 
BlahBlahBlahBlah & $10$ & $10$ & $10$ & $10$\\ 
BlahBlahBlah & $10$ & $10$ & $10$ & $10$\\ 
BlahBlahBlah & $10$ & $10$ & $10$ & $10$\\ 
\bottomrule
\end{tabular}
\end{minipage}
}
\end{document}

有人知道怎么得到它吗?谢谢!

答案1

由于您添加了附加列,因此您需要&在主要内容中添加附加列以跳过新列。为了跳过不需要的行上的垂直规则,我使用了\multicolumn{2}{c}{}

在此处输入图片描述

代码:

\documentclass{article}
\usepackage{array}    % \extrarowheight macro
\usepackage{graphicx} % \rotatebox macro
\usepackage{multirow} % \multirow macro
\usepackage{booktabs} % for \toprule, \midrule, \bottomrule
\begin{document}


\begin{tabular}{|c|ccccc@{}}
\cmidrule[0.9pt](l){3-6}
\multicolumn{2}{c}{} & \multicolumn{4}{c@{}}{Prediction}\\
\cmidrule(l){3-6}
\multicolumn{2}{c}{}& Blah & BlahBlahBlahBlah & BlahBlahBlah & BlahBlahBlah \\
\cmidrule(l){2-6}
\multirow{4}{*}{\rotatebox[origin=c]{90}{Expert}}
&Blah & $10$ & $10$ & $10$ & $10$\\ 
&BlahBlahBlahBlah & $10$ & $10$ & $10$ & $10$\\ 
&BlahBlahBlah & $10$ & $10$ & $10$ & $10$\\ 
&BlahBlahBlah & $10$ & $10$ & $10$ & $10$\\ 
\cmidrule[0.9pt](l){2-6}
\end{tabular}
\end{document}

答案2

只需一个补充列和一个命令就很容易了\rotatebox。我要指出的是,您的makebox命令完全没有必要,并且 minpage 环境产生的垂直间距太小。但也许您有充分的理由不使用表格环境。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe, nomarginpar]{geometry}

\usepackage{array} % \extrarowheight macro
\usepackage{graphicx} % \rotatebox macro
\usepackage{multirow} % \multirow macro
\usepackage{booktabs} % for \toprule, \midrule, \bottomrule

\begin{document}

Before: \\

\noindent\makebox[\textwidth][c]{
\begin{minipage}[c]{\textwidth}
\centering
\begin{tabular}{@{}ccccc@{}}
\toprule
Expert & \multicolumn{4}{c@{}}{Prediction}\\
\cmidrule(l){2-5}
& Blah & BlahBlahBlahBlah & BlahBlahBlah & BlahBlahBlah \\
\midrule
Blah & $10$ & $10$ & $10$ & $10$\\
BlahBlahBlahBlah & $10$ & $10$ & $10$ & $10$\\
BlahBlahBlah & $10$ & $10$ & $10$ & $10$\\
BlahBlahBlah & $10$ & $10$ & $10$ & $10$\\
\bottomrule
\end{tabular}
\end{minipage}
}

\vspace{5cm}

After: \\

\noindent
\begin{minipage}{\linewidth}
\centering
\begin{tabular}{@{}c <{\enspace }@{}ccccc@{}}
\cmidrule[\heavyrulewidth]{3-6}
 & & \multicolumn{4}{c@{}}{Prediction}\\
\cmidrule(l){3-6}
 & & Blah & BlahBlahBlahBlah & BlahBlahBlah & BlahBlahBlah \\
\cmidrule{2-6}
\multirow{5}{*}{\rotatebox{90}{\enspace Expert}} & Blah & $10$ & $10$ & $10$ & $10$\\
 & BlahBlahBlahBlah & $10$ & $10$ & $10$ & $10$\\
 & BlahBlahBlah & $10$ & $10$ & $10$ & $10$\\
 & BlahBlahBlah & $10$ & $10$ & $10$ & $10$\\
\cmidrule[\heavyrulewidth]{2-6}
\end{tabular}
\end{minipage}

\end{document} 

在此处输入图片描述

相关内容