0

I have the following LaTeX code for two tables:

\begin{table}[h]
    \scriptsize
    \centering
    \begin{tabular}{c|c}
       \textbf{Brand} & \textbf{Customer Engagement Average}   \\ \hline
     Apple & 1,937,852.45  \\ 
     Huawei & 156,962.065  \\ 
     Samsung & 174,166.98  \\
     \end{tabular}
\caption{Average Brand Customer Engagement}
\label{brand_ce}

%\end{table}

%\begin{table}[h] \scriptsize \centering \begin{tabular}{c|c} \textbf{Brand} & \textbf{Customer Satisfaction Score Average} \ \hline Apple & 3.37 \ Huawei & 4.049 \ Samsung & 3.76 \

     \end{tabular}
\caption{Average Brand Customer Satisfaction Score}
\label{brand_sscore}

\end{table}

Those tables are on top of each other as the following figure:

enter image description here

I need to to put those tables side by side.

Peter
  • 105
  • 2
    Remove the empty line in between them (that starts a new paragraph). Also, to get the captions at the correct position use minipage inside the table environment, like this: \begin{minipage}{0.45\linewidth}\centering\begin{tabular}...\end{tabular}\caption{...}\end{minipage}\hfill\begin{minipage}{0.45\linewidth}...\end{minipage}. You can play with the 0.5\linewidth to get something more pleasing. – Skillmon Jul 29 '20 at 06:47
  • @Skillmonlikestopanswers.xyz I've tried your answer and it works, thanks and I appreciate – Peter Jul 29 '20 at 06:51
  • Why not combine the information into a single table? You can then avoid repeating the first column. – leandriis Jul 29 '20 at 07:27

2 Answers2

2

I suggest using floatrow and the S column type for the second column, to align numbers on the decimal dot. Note that traditionally, tables have their captions above tables, which is done automatically by float row. Furthermore, loading geometry, you'll have more sensible margins (this supposes you don't need marginal notes).

\documentclass[11pt]{article}
\usepackage{geometry} 
\usepackage{makecell}
\renewcommand{\theadfont}{\small\bfseries}
\usepackage{siunitx} 
\usepackage{caption, floatrow}

\begin{document}

\begin{table}[h] \centering \setlength{\extrarowheight}{2pt} \sisetup{table-number-alignment=center, group-separator={,}} \captionsetup{format=hang, justification=raggedright} \begin{floatrow} \ttabbox{\caption{Average Brand Customer Engagement} \label{brand_ce}}% {\centering\begin{tabular}{r|S[table-format=7.3]} \textbf{Brand} & {\thead{Customer Engagement\ Average}} \ \hline Apple & 1937852.45 \ Huawei & 156962.065 \ Samsung & 174166.98 \end{tabular}} \qquad \ttabbox{\caption{Average Brand Customer Satisfaction Score} \label{brand_sscore}}% {\begin{tabular}{r|S[table-format=1.3]} \thead[b]{Brand} & {\thead{Customer Satisfaction\ Score Average}} \ \hline Apple & 3.37 \ Huawei & 4.049 \ Samsung & 3.76 \end{tabular}} \end{floatrow} \end{table}

\end{document}

enter image description here

Bernard
  • 271,350
0

From the comments above

enter image description here

\begin{table}[h]
    \scriptsize
    \centering
    \begin{tabular}{c|cc}
        \textbf{Brand} & \multicolumn{2}{c}{\textbf{Customer Average}}  \\ 
        &\textbf{-Engagement-} &\textbf{-Satisfaction Score-}\\\hline
        Apple & 1,937,852.45& 3.37   \\ 
        Huawei & 156,962.065  & 4.049  \\ 
        Samsung & 174,166.98& 3.76  \\ 
    \end{tabular}
    \caption{Average Brand Customer Engagement}
    \label{brand_ce}

\end{table}

js bibra
  • 21,280