0

I would like to align Euclidean_L1 text is in center. I am generating tables from Excel2Latex plugin where everything is fine despite of "Euclidean_L1"

Code

\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{cccccr}
    \toprule
    \multirow{2}[4]{*}{Models} & \multicolumn{5}{p{15.215em}}{Euclidean\_L1} \\
\cmidrule{2-6}          & Prec  & Recall & F1-Sco & Acc   & \multicolumn{1}{c}{AUC} \\
    \midrule
    OpenFace & 52.41 & 53.69 & 53.04 & 52.67 & \multicolumn{1}{c}{55} \\
    DeepID & 52.75 & 38.97 & 44.83 & 52.24 & \multicolumn{1}{c}{52.51} \\
    DeepFace & 53    & 45.08 & 48.72 & 52.76 & \multicolumn{1}{c}{54.03} \\
    FaceNet & 56.75 & 57.94 & 57.34 & 57.08 & \multicolumn{1}{c}{62.25} \\
    \midrule
    VGGFace & \textcolor[rgb]{ 1,  0,  0}{\textbf{64.27}} & \textcolor[rgb]{ 1,  0,  0}{\textbf{48.98}} & \textcolor[rgb]{ 1,  0,  0}{\textbf{55.59}} & \textcolor[rgb]{ 1,  0,  0}{\textbf{61.04}} &  \\
    \bottomrule
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%

Screenshot

enter image description here

3
  • \multicolumn{5}{c}{Euclidean_L1} horizontally centers the text.
    – leandriis
    Jan 21, 2021 at 7:03
  • Thank you. So what is this text {p{15.215em}}? Jan 21, 2021 at 7:28
  • Width of column or cell in your case: it is equal to 15.215 widths of letter M. Content in this column is justified and can have many lines. In the case of the short one line text, as is your case, it will start at left border of cell.
    – Zarko
    Jan 21, 2021 at 7:50

1 Answer 1

0

In order to horizontally center the contents of the \multicolumn, use c instead of p{15.215em}.

I have also simplified your code a bit by using the predefined color red and I also removed all unnecessary \multicolumn{1}{c} commands.

For comparison, I also included a second example, in which I used siunitx to improve the alignment of the numbers in the table. (Also, do you really need a red color and bold text to highlight the numbers in the last column? Wouldn't one of the be already sufficient?)

enter image description here

\documentclass{article}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{xcolor}


%%% only used in the second example code:
\usepackage{siunitx}
\usepackage{etoolbox}
\newrobustcmd{\Red}{\color{red}}
\robustify\bfseries

\begin{document}

\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{cccccc}
    \toprule
    \multirow{2}[4]{*}{Models} & \multicolumn{5}{c}{Euclidean\_L1} \\
\cmidrule{2-6}          & Prec  & Recall & F1-Sco & Acc   & {AUC} \\
    \midrule
    OpenFace & 52.41 & 53.69 & 53.04 & 52.67 & 55 \\
    DeepID & 52.75 & 38.97 & 44.83 & 52.24 & 52.51 \\
    DeepFace & 53    & 45.08 & 48.72 & 52.76 & 54.03 \\
    FaceNet & 56.75 & 57.94 & 57.34 & 57.08 & 62.25 \\
    \midrule
    VGGFace & \textcolor{red}{\textbf{64.27}} & \textcolor{red}{\textbf{48.98}} & \textcolor{red}{\textbf{55.59}} & \textcolor[rgb]{ 1,  0,  0}{\textbf{61.04}} &  \\
    \bottomrule
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%

\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{l*{5}{S[table-format=2.2, detect-weight]}}
    \toprule
    Models & \multicolumn{5}{c}{Euclidean\_L1} \\
\cmidrule{2-6}          & {Prec}  & {Recall} & {F1-Sco} & {Acc}   & {AUC} \\
    \midrule
    OpenFace & 52.41 & 53.69 & 53.04 & 52.67 & 55 \\
    DeepID & 52.75 & 38.97 & 44.83 & 52.24 & 52.51 \\
    DeepFace & 53    & 45.08 & 48.72 & 52.76 & 54.03 \\
    FaceNet & 56.75 & 57.94 & 57.34 & 57.08 & 62.25 \\
    \midrule
    VGGFace & \Red 64.27 & \bfseries 48.98 & \Red\bfseries 55.59 & 61.04 &  \\
    \bottomrule
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%


\end{document}

You must log in to answer this question.

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