3

In the following table:

\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}

The negative numbers in the column Correlation coefficient are shown as positive. The negative sign - is not shown. I tried both $-18$ and $-$ 0.2 but none of them works.

How to solve this issue?

2
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.
    – BambOo
    Sep 12, 2019 at 15:04
  • The sign in your MWE is not a - as in the body of your question, it is . The latter is not by default recognised by LaTeX inside a table or outside of it, see tex.stackexchange.com/questions/334025/…
    – Au101
    Sep 12, 2019 at 15:14

1 Answer 1

7

Some of the minus signs were Unicode en-dashes. Changing to a hyphen inside the dollar signs, cured the errors.

However, I suggest that you load either siunitx or dcolumn to align you column at the decimal sign. Also, booktabs, more space and no vertical rules will increase readability. See example 2.

Example 1

enter image description here

\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}

Example 2

With booktabs, dcolumn and no vertical space. d-column is in math mode, so no $ is needed. However, headings has to be enclosed in a \multicolumn. According to my textbooks, table heading should be bottom aligned, not vertically centred. You may also reduce the font size one grade.

enter image description here

\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}

Not the answer you're looking for? Browse other questions tagged .