下表中:
\documentclass[12pt]{article}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{float}
\begin{document}
\begin{table}[H]
\centering
\small
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\textbf{Representation} & \textbf{Configuration} & \textbf{Correlation} & \textbf{p-value} & \textbf{\begin{tabular}[c]{@{}c@{}}Correlation\\ coefficient\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}\# classes with\\ significant\\ correlation\end{tabular}} \\ \hline
\multirow{6}{*}{Test suite} & \multirow{6}{*}{Without reduction} & Coverage and AC & \multirow{6}{*}{\textless 0.001} & $−0.18$ & 9 \\ \cline{3-3} \cline{5-6}
& & Coverage and ND & & $−$ 0.2 & 4 \\ \cline{3-3} \cline{5-6}
& & Coverage and NV & & −0.19 & 9 \\ \cline{3-3} \cline{5-6}
& & Coverage and IC & & 0.21 & 8 \\ \cline{3-3} \cline{5-6}
& & Coverage and PIC & & 0.2 & 4 \\ \cline{3-3} \cline{5-6}
& & Coverage and DBI & & 0.21 & 9 \\ \hline
\end{tabular}
\end{table}
\end{document}
列中的负数Correlation coefficient
显示为正数。-
不显示负号。我尝试了两种$-18$
方法,$-$ 0.2
但都没有用。
如何解决这个问题?
答案1
有些减号是 Unicode 短划线。将美元符号改为连字符后,错误就解决了。
不过,我建议你加载希尼奇或者列将列对齐到小数点处。此外,书签,更多空间和无垂直线将提高可读性。参见示例 2。
示例 1
\documentclass{article}
\usepackage{multirow}
\usepackage[margin=2cm]{geometry}
\begin{document}
\begin{table}
\centering\small
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\textbf{Representation}
& \textbf{Configuration}
& \textbf{Correlation}
& \textbf{p-value}
& \textbf{\begin{tabular}[c]{@{}c@{}}Correlation\\ coefficient\end{tabular}}
& \textbf{\begin{tabular}[c]{@{}c@{}}\# classes with\\ significant\\ correlation\end{tabular}}\\
\hline
\multirow{6}{*}{Test suite}
& \multirow{6}{*}{Without reduction}
& Coverage and AC
& \multirow{6}{*}{\textless 0.001}
& $-0.18$
& 9\\
\cline{3-3} \cline{5-6}
& & Coverage and ND & & $-$0.2 & 4 \\
\cline{3-3} \cline{5-6}
& & Coverage and NV & & $-$0.19 & 9 \\
\cline{3-3} \cline{5-6}
& & Coverage and IC & & 0.21 & 8 \\
\cline{3-3} \cline{5-6}
& & Coverage and PIC & & 0.2 & 4 \\
\cline{3-3} \cline{5-6}
& & Coverage and DBI & & 0.21 & 9 \\
\hline
\end{tabular}
\end{table}
\end{document}
示例 2
和书签,列并且没有垂直空格。d-column
处于数学模式,因此不需要 $。但是,标题必须括在 中\multicolumn
。根据我的教科书,表格标题应底部对齐,而不是垂直居中。您也可以将字体大小减小一级。
\documentclass{article}
\usepackage{multirow, dcolumn, booktabs}
\usepackage[margin=2cm]{geometry}
\begin{document}
\begin{table}[th!]
\centering\small
\begin{tabular}{@{}cclcD{.}{.}{-2}c@{}}
\toprule
\textbf{Representation}
&\textbf{Configuration}
&\multicolumn{1}{>{\centering\arraybackslash\hspace{0pt}}b{2.5cm}}{\bfseries Correlation}
&\textbf{p-value}
&\multicolumn{1}{>{\centering\arraybackslash\hspace{0pt}}b{2.5cm}}{\bfseries Correlation coefficient}
&\multicolumn{1}{>{\centering\arraybackslash\hspace{0pt}}b{2.5cm}}{\bfseries \# classes with significant correlation}\\
\midrule
\multirow{6}{*}{Test suite}
&\multirow{6}{*}{Without reduction}
& Coverage and AC
&\multirow{6}{*}{\textless 0.001}
& -0.18
&9 \\
& & Coverage and ND & & -0.2 & 4 \\
& & Coverage and NV & & -0.19 & 9 \\
& & Coverage and IC & & 0.21 & 8 \\
& & Coverage and PIC & & 0.2 & 4 \\
& & Coverage and DBI & & 0.21 & 9 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}