在关注了与问题相同的主题相关的问题之后使用 \cline,我使用了基于的建议另一个相关问题。但是,我仍然面临同样的问题,即水平线被单元格的颜色覆盖。令人困惑的是它不一致。它对某些线条有效,但对其他线条无效。
\documentclass[journal]{IEEEtran}
\usepackage{amssymb, amsmath, amsthm, amsfonts}
\usepackage{tabularx}
\usepackage[dvips]{graphicx}
\usepackage{epsfig}
\usepackage{algorithm,algorithmic}
\usepackage{subfigure}
\usepackage[table]{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{multirow}
\usepackage{footnote}
\usepackage{arydshln}
\usepackage[skip=5pt]{caption} % Unifies the distance between caption and float
\newtheorem{theorem}{Theorem}
\newtheorem{definition}{Definition}
\newtheorem{notation}{Notation}
\newtheorem{lemma}{Lemma}
\newtheorem{property}{Property}
\DeclareMathOperator*{\argmax}{arg\,max} %Defines a new operation argmax with no space
\usepackage[hyphens]{url}
\usepackage{array}
\usepackage{rotating}
\usepackage{color}
\usepackage{xcolor}
\usepackage{ragged2e}
\newcolumntype{P}[1]{>{\RaggedRight}p{#1}}
\usepackage{cite}
\bibliographystyle{IEEEtran}
\usepackage{pifont}% http://ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%
\usepackage{bm} % For bold math notations use \bm{$..$}
\usepackage{arydshln} % For dashed lines. \hdashline and \cdashline commands which are the dashed counterparts of \hline and \cline
\usepackage[table]{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{hhline}
\usepackage{enumitem}
\newcommand{\inchsign}{^{\prime\prime}}
\usepackage{bm} % For bold math notations use \bm{$..$}
\begin{document}
\begin{table*}[htpb]
\begin{minipage}{\linewidth}
\renewcommand{\thefootnote}{\thempfootnote}
\center{\caption{\label{tab:classification} Classification.}
\scalebox{1}
{{
\begin{tabular}{m{3cm} m{1cm} m{0.75cm} m{0.25cm} m{2.7cm} m{1.45cm} m{1.45cm} m{1.45cm} m{1.45cm} m{1.45cm}}
\hhline{*{10}{|-}|}
\multicolumn{5}{|c|}{\multirow{2}{*}{Proposed Classification}} & \multicolumn{1}{c|}{\multirow{2}{*}{UShort}} & \multicolumn{1}{c|}{\multirow{2}{*}{Short}} & \multicolumn{1}{c|}{\multirow{2}{*}{Medium}} & \multicolumn{1}{c|}{\multirow{2}{*}{Long}} & \multicolumn{1}{c|}{\multirow{2}{*}{ULong}}\\
\multicolumn{5}{|c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} \\ \hhline{*{10}{|-}|}
\multicolumn{1}{|c|}{\multirow{12}{*}{Indoor}} & \multicolumn{1}{c|}{\multirow{7}{*}{Point}} & \multicolumn{1}{c|}{\multirow{4}{*}{LOS}} & \multicolumn{1}{c|}{\multirow{2}{*}{F}} & \multicolumn{1}{c|}{\multirow{2}{*}{I / PC / LOS / F}} & \multicolumn{1}{c|}{\multirow{2}{*}{\parbox{1.45cm}{}}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor{blue!25}} & \multicolumn{1}{c|}{\cellcolor{blue!25}} \\
\multicolumn{1}{|c|}{\multirow{12}{*}{$(I)$}} & \multicolumn{1}{c|}{\multirow{7}{*}{Coverage}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor{blue!25}} & \multicolumn{1}{c|}{\cellcolor{blue!25}} \\
\hhline{*{3}{|~}*{7}{|-}|}
\multicolumn{1}{|c|}{} & \multicolumn{1}{c|}{\multirow{7}{*}{$(PC)$}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\multirow{2}{*}{M}} & \multicolumn{1}{c|}{\multirow{2}{*}{I / PC / LOS / M}} & \multicolumn{1}{c|}{\multirow{2}{*}{\parbox{1.45cm}{}}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor{blue!25}} & \multicolumn{1}{c|}{\cellcolor{blue!25}} \\
\multicolumn{1}{|c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor{blue!25}} & \multicolumn{1}{c|}{\cellcolor{blue!25}} \\
\hhline{*{2}{|~}*{8}{|-}|}
\multicolumn{1}{|c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\multirow{4}{*}{NLOS}} & \multicolumn{1}{c|}{\multirow{2}{*}{F}} & \multicolumn{1}{c|}{\multirow{2}{*}{I / PC / NLOS / F}} & \multicolumn{1}{c|}{\multirow{2}{*}{\parbox{1.45cm}{}}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor{blue!25}} & \multicolumn{1}{c|}{\cellcolor{blue!25}} \\
\multicolumn{1}{|c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor{blue!25}} & \multicolumn{1}{c|}{\cellcolor{blue!25}} \\
\hhline{*{3}{|~}*{7}{|-}|}
\multicolumn{1}{|c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\multirow{2}{*}{M}} & \multicolumn{1}{c|}{\multirow{2}{*}{I / PC / NLOS / M}} & \multicolumn{1}{c|}{\multirow{2}{*}{\parbox{1.45cm}{NPA}}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor{blue!25}} & \multicolumn{1}{c|}{\cellcolor{blue!25}} \\
\multicolumn{1}{|c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor{blue!25}} & \multicolumn{1}{c|}{\cellcolor{blue!25}} \\
\hhline{*{1}{|~}*{9}{|-}|}
\multicolumn{1}{|c|}{}&\multicolumn{1}{c|}{\multirow{2}{*}{Cellular}} & \multicolumn{2}{c|}{\multirow{2}{*}{LOS}} & \multicolumn{1}{c|}{\multirow{2}{*}{I / CC / LOS}} & \multicolumn{1}{c|}{\multirow{2}{*}{\parbox{1.45cm}{}}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor{blue!25}} & \multicolumn{1}{c|}{\cellcolor{blue!25}} \\
\multicolumn{1}{|c|}{} & \multicolumn{1}{c|}{\multirow{2}{*}{Coverage}} & \multicolumn{2}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor{blue!25}} & \multicolumn{1}{c|}{\cellcolor{blue!25}} \\ \hhline{*{2}{|~}*{8}{|-}}
\multicolumn{1}{|c|}{}&\multicolumn{1}{c|}{\multirow{2}{*}{$(CC)$} } & \multicolumn{2}{c|}{\multirow{2}{*}{NLOS}} & \multicolumn{1}{c|}{\multirow{2}{*}{I / CC / NLOS}} & \multicolumn{1}{c|}{\multirow{2}{*}{\parbox{1.45cm}{}}} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor{blue!25}} & \multicolumn{1}{c|}{\cellcolor{blue!25}} \\
\multicolumn{1}{|c|}{} & \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\cellcolor{blue!25}} & \multicolumn{1}{c|}{\cellcolor{blue!25}} \\
\hhline{*{10}{|-}|}
\end{tabular}
}}}
\end{minipage}
\end{table*}
\end{document}
我面临的另一个问题是,当我将表格放在论文正文中时,垂直线会发生位移。当我隔离表格代码以创建 MWE 时,问题就消失了。
答案1
垂直线错位的原因是arydshln
和包之间存在冲突。如果可以不用,则hhline
需要删除。如果无法删除,则可以尝试,它是一个功能强大的一体化表格包,可以与 一起使用,并且具有自己的虚线样式。arydshln
arydshln
tabu
hhline
因此,在您的序言中,您可以使用\usepackage{hhline,tabu}
,并获取虚线,只需定义您自己的样式,如:
\newtabulinestyle{ mydashed=.5pt on 1.5pt off 1.5pt }
并将其用作常规列说明符,如c
、l
和r
。
答案2
离题但有帮助:-):你的表格没有必要那么复杂......
- 基本问题解决的是阿博阿马尔回答,但我建议你不要在表格中使用虚线
- 在序言中,有些包被加载了两次,有些则加载了三次
xcolor
取代color
。仅加载就足够了xcolor
- 包
subfigure
已过时。而是使用subfig
或subcaption
- 没有理由将所有列都声明为
m
类型。只需为前三列定义宽度即可,其他列最好为c
类型。而且似乎没有特殊理由使用m{...}
类型。我宁愿使用p{...}
- 都是
\multicolumn{1}{...}{...}
多余的 - 使用`multirow是错误的,只需将它们的内容写成一行并将它们重叠即可
- 利用最新版本软件包的新选项
multirow
:{=}
- 而
\center{... tcaption + table ...}
只需使用“\centering”即可 - 仅当单元格必须跨越更多表格行时使用
multirow
。它不是为了在单元格内容周围留出更多垂直空间。有关此更改arraystretch
(请参阅姆韦以下) - 对最后两列单元格进行着色比对整列进行着色更有效,并且
\colorcell
仅用于第一行的例外情况 - 不要使用
scalebox
......这是使表格适合列宽的最后手段
考虑上述评论后,您的表格变成:
\documentclass[journal]{IEEEtran}
\usepackage{amssymb, amsmath, amsthm, amsfonts}
\usepackage{tabularx}
\usepackage[dvips]{graphicx}% DVIPS OPTION IS SUPERFLUOUS
\usepackage{epsfig}
\usepackage{algorithm,algorithmic}
%\usepackage{subfigure} % ABSOLETE
\usepackage[table]{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{multirow}
\usepackage{footnote}
%\usepackage{arydshln} % TROUBLEMAKER
\usepackage[skip=5pt]{caption} % Unifies the distance between caption and float
\newtheorem{theorem}{Theorem}
\newtheorem{definition}{Definition}
\newtheorem{notation}{Notation}
\newtheorem{lemma}{Lemma}
\newtheorem{property}{Property}
\DeclareMathOperator*{\argmax}{arg\,max} %Defines a new operation argmax with no space
\usepackage[hyphens]{url}
\usepackage{array}
\usepackage{rotating}
%\usepackage{color}
%\usepackage{xcolor}% <-- SECOND TIME
\usepackage{ragged2e}
\newcolumntype{P}[1]{>{\RaggedRight}p{#1}}
\usepackage{cite}
\bibliographystyle{IEEEtran}
\usepackage{pifont}% http://ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%
\usepackage{bm} % For bold math notations use \bm{$..$}
%\usepackage{arydshln} % For dashed lines. \hdashline and \cdashline commands which are the dashed counterparts of \hline and \cline
%\usepackage[table]{xcolor}% <-- THIRD TIME
\usepackage{hhline}
\usepackage{enumitem}
%\usepackage{bm} % SECOND TIME
\newcommand{\inchsign}{^{\prime\prime}}
% just for test
\usepackage[floats, tightpage, active]{preview}
\setlength\PreviewBorder{3mm}
\begin{document}
\begin{table*}[htpb]
\begin{minipage}{\linewidth}% FOR FOOTNOTES BELOW TABLE?
\renewcommand{\thefootnote}{\thempfootnote}
\centering
\renewcommand\arraystretch{1.5}
\caption{\label{tab:classification} Classification.}
\begin{tabular}{|*{3}{p{1.2cm}|}
*{5}{c|}
*{2}{>{\columncolor{blue!25}}c|}
}
\hhline{*{10}{|-}|}
\multicolumn{5}{|c|}{Proposed Classification}
& UShort & Short & Medium & \cellcolor{white}{Long}
& \cellcolor{white}{ULong} \\
\hhline{*{10}{|-}|}
\multirow{6}{=}{Indoor (I)}
& \multirow{4}{=}[-1ex]{Point Coverage (PC)}
& \multirow{2}{=}{LOS}
& F & I / PC / LOS / F & & & & & \\
\hhline{*{3}{|~}*{7}{|-}|}
& & & M & I / PC / LOS / M & & & & & \\
\hhline{*{2}{|~}*{8}{|-}|}
& & \multirow{2}{=}{NLOS}
& F & I / PC / NLOS / F & & & & & \\
\hhline{*{3}{|~}*{7}{|-}|}
& & & M & I / PC / NLOS / M & NPA & & & & \\
\hhline{*{1}{|~}*{9}{|-}|}
& \multirow{2}{=}{Cellular Coverage (CC)}
& \multicolumn{2}{c|}{LOS} & I / CC / LOS & & & & & \\
\hhline{*{2}{|~}*{8}{|-}}
& & \multicolumn{2}{c|}{NLOS} & I / CC / NLOS & & & & & \\
\hhline{*{10}{|-}|}
\end{tabular}
\end{minipage}
\end{table*}
\end{document}
答案3
您可以使用 轻松做到这{NiceTabular}
一点nicematrix
。
\documentclass[journal]{IEEEtran}
\usepackage{nicematrix}
\begin{document}
\begin{table*}[htpb]
\centering
\renewcommand\arraystretch{1.5}
\caption{\label{tab:classification} Classification.}
\begin{NiceTabular}{*{3}{p{1.2cm}}*{7}{c}}[hvlines]
\CodeBefore
\rectanglecolor{blue!25}{2-9}{7-10}
\Body
\Block{1-5}{Proposed Classification} & & & &
& UShort & Short & Medium & Long & ULong \\
\Block{6-1}{Indoor (I)}
& \Block{4-1}{Point\\ Coverage\\ (PC)}
& \Block{2-1}{LOS}
& F & I / PC / LOS / F \\
& & & M & I / PC / LOS / M \\
& & \Block{2-1}{NLOS}
& F & I / PC / NLOS / F \\
& & & M & I / PC / NLOS / M & NPA \\
& \Block{2-1}{Cellular\\ Coverage\\ (CC)}
& \Block{1-2}{LOS} & & I / CC / LOS \\
& & \Block{1-2}{NLOS} & & I / CC / NLOS \\
\end{NiceTabular}
\end{table*}
\end{document}
- 您需要多次编译。
- 在 中
{NiceTabular}
,您有一个命令\Block
可以水平和垂直合并单元格。 - 您有一把钥匙
hvlines
,可以绘制块中除外的所有规则。 - 您有命令来为单元格、列和行着色。使用这些工具,您不会在某些 PDF 查看器中看到使用 工具时出现的伪影
colortbl
。 &
如果行的最后一个单元格是空的,则无需用“与”符号 ( ) 填写行。