1

I have two tables, and I want to put them in the same row in a two-column mode. But when I use the code below, none of them are aligned, and a table cannot be displayed completely. What should I do? Thank you!

enter image description here

   \begin{table*}[t]
        \begin{minipage}[t]{0.4\linewidth}
            \begin{center}
                \begin{tabular}[t]{|c|c|c|}
                    \hline
                    data load nums  & W        & L       \\ \hline
                    p1 (k/ms) & $3.000*10^8$  &$3.000*10^8$  \\ \hline
                    p2 (k/ms)  &$3.000*10^8$  & $3.000*10^8$   \\ \hline
                    p3 (k/ms) & $3.000*10^8$ & $3.000*10^8$ \\ \hline
                    Total (k/ms) & $3.000*10^8$  &$3.000*10^8$  \\ \hline
                \end{tabular}
                \caption{Process.}
                \label{table:formatting}
            \end{center}
        \end{minipage}\hfill
        \begin{minipage}[t]{0.6\linewidth}
            \begin{center}
                \begin{tabular}[t]{|c|c|c|c|c|c|c|}
                    \hline
                    & \textbf{\begin{tabular}[c]{@{}c@{}}p1 TB\\ Alg.1\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}sender \& pcc \\ Alg.1\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}sender only \\ Alg.1\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}p2 TB\\ Alg.2\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}sender \& pcc \\ Alg.2\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}sender only \\ Alg.2\end{tabular}} \\ \hline
                    \textbf{L1D} & 0.041\%                                                        & 0.111\%                                                                 & 0.111\%                                                             & 0.111\%                                                     & 0.111\%                                                            & 0.111\%                                                      \\ \hline
                    \textbf{L2}  & 3.586\%                                                        & 0.111\%                                                       & 0.111\%                                                        & 0.111\%                                               & 0.111\%                                                           & 0.111\%                                                     \\ \hline
                    \textbf{LLC} & 34.379\%                                                       & 0.111\%                                                          & 0.111\%                                                        & 0.111\%                                           & 0.111\%                                                             & 0.111\%                                                      \\ \hline
                \end{tabular}
                \caption{ Algorithm 1.}
                \label{table:formatting}
            \end{center}
        \end{minipage}%
    \end{table*} 
Gerrie
  • 271

2 Answers2

1

Since documentclass, margins and font sizes are unknow, the following three suggestions are based on assumptions:

enter image description here

enter image description here

enter image description here

\documentclass[10pt,twocolumn]{article}

\usepackage{makecell} \usepackage{booktabs} \usepackage{siunitx}

\usepackage{lipsum} % Just for dummy text. Do not use in actual document. \begin{document} \lipsum

\begin{table} \centering \begin{tabular}[t]{|c|c|c|c|c|c|c|} \hline & \textbf{\begin{tabular}[c]{@{}c@{}}p1 TB\ Alg.1\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}sender & pcc \ Alg.1\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}sender only \ Alg.1\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}p2 TB\ Alg.2\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}sender & pcc \ Alg.2\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}sender only \ Alg.2\end{tabular}} \ \hline \textbf{L1D} & 0.041% & 0.111% & 0.111% & 0.111% & 0.111% & 0.111% \ \hline \textbf{L2} & 3.586% & 0.111% & 0.111% & 0.111% & 0.111% & 0.111% \ \hline \textbf{LLC} & 34.379% & 0.111% & 0.111% & 0.111% & 0.111% & 0.111% \ \hline \end{tabular} \caption{ Algorithm 1.} \label{table:formatting} \end{table}

\begin{table} \centering \begin{tabular}[t]{|c|c|c|} \hline data load nums & W & L \ \hline p1 (k/ms) & $3.00010^8$ &$3.00010^8$ \ \hline p2 (k/ms) &$3.00010^8$ & $3.00010^8$ \ \hline p3 (k/ms) & $3.00010^8$ & $3.00010^8$ \ \hline Total (k/ms) & $3.00010^8$ &$3.00010^8$ \ \hline \end{tabular} \caption{Process.} \label{table:formatting} \end{table}

\lipsum

\begin{table}[t] \begin{minipage}[t]{0.35\linewidth} \centering \caption{Process.} \label{table:formatting} \begin{tabular}[t]{c{2}{S[table-format=1.2]}} \toprule \thead{data load\ nums\ (\si{k\per\milli\second})} & {\thead{W $\cdot 10^8$}} & {\thead{L $\cdot 10^8$}} \ \midrule p1 & 3.00 & 3.00 \ p2 & 3.00 & 3.00 \ p3 & 3.00 & 3.00 \ Total & 3.00 & 3.00 \ \bottomrule \end{tabular} \end{minipage}\hfill \begin{minipage}[t]{0.65\linewidth} \centering \caption{ Algorithm 1.} \label{table:formatting} \begin{tabular}[t]{lS[table-format=2.3]{5}{S[table-format=1.3]}} \toprule & \multicolumn{3}{c}{Alg.1} & \multicolumn{3}{c}{Alg.2}\ \cmidrule(r){2-4} \cmidrule(l){5-7} & {\thead{p1 TB\ (%)}} & {\thead{sender \ & pcc (%)}} & {\thead{sender \ only (%)}}
& {\thead{p1 TB\ (%)}} & {\thead{sender \ & pcc (%)}} & {\thead{sender \ only (%)}}\ \midrule L1D & 0.041 & 0.111 & 0.111 & 0.111 & 0.111 & 0.111 \ L2 & 3.586 & 0.111 & 0.111 & 0.111 & 0.111 & 0.111 \ LLC & 34.379 & 0.111 & 0.111 & 0.111 & 0.111 & 0.111 \ \bottomrule \end{tabular} \end{minipage}% \end{table
}

\lipsum
\lipsum 


\begin{table} \centering \caption{ Algorithm 1.} \label{table:formatting} \begin{tabular}[t]{lS[table-format=2.3]{5}{S[table-format=1.3]}} \toprule & \multicolumn{3}{c}{Alg.1} & \multicolumn{3}{c}{Alg.2}\ \cmidrule(r){2-4} \cmidrule(l){5-7} & {\thead{p1 TB (%)}} & {\thead{sender & pcc (%)}} & {\thead{sender only (%)}}
& {\thead{p1 TB (%)}} & {\thead{sender & pcc (%)}} & {\thead{sender only (%)}}\ \midrule L1D & 0.041 & 0.111 & 0.111 & 0.111 & 0.111 & 0.111 \ L2 & 3.586 & 0.111 & 0.111 & 0.111 & 0.111 & 0.111 \ LLC & 34.379 & 0.111 & 0.111 & 0.111 & 0.111 & 0.111 \ \bottomrule \end{tabular} \end{table*}

\begin{table} \centering \caption{Process.} \label{table:formatting} \begin{tabular}[t]{c*{2}{S[table-format=1.2]}} \toprule \thead{data load nums\ (\si{k\per\milli\second})} & {\thead{W $\cdot 10^8$}} & {\thead{L $\cdot 10^8$}} \ \midrule p1 & 3.00 & 3.00 \ p2 & 3.00 & 3.00 \ p3 & 3.00 & 3.00 \ Total & 3.00 & 3.00 \ \bottomrule \end{tabular} \end{table}

\lipsum \end{document}

leandriis
  • 62,593
1

A possibility with floatrow and makecell(and caption to have a decent spacing between caption and table):

\documentclass{article}
\usepackage[showframe]{geometry} 
\usepackage{caption} 
\usepackage{makecell}
\renewcommand{\theadfont}{\small\bfseries}
\usepackage[valign=t,heightadjust=all]{floatrow}

\begin{document}

\begin{table} \centering\setlength{\tabcolsep}{3pt} \begin{floatrow}[2] \ttabbox[\FBwidth]{\caption{Process.}% \label{table:formatting} }{ \begin{tabular}[t]{|c|c|c|} \hline \makecell{data load\ nums} & W & L \ \hline \makecell{p1\ (k/ms)} & $3.00010^8$ &$3.00010^8$ \ \hline \makecell{p2\ (k/ms)} &$3.00010^8$ & $3.00010^8$ \ \hline \makecell{p3 \(k/ms)} & $3.00010^8$ & $3.00010^8$ \ \hline \makecell{Total \(k/ms)} & $3.00010^8$ &$3.00010^8$ \ \hline \end{tabular}} \ttabbox[\FBwidth]{\caption{ Algorithm 1.} \label{table:formatting1}}% {\begin{tabular}[t]{|c|c|c|c|c|c|c|} \hline & \thead{p1 TB\ Alg.1 \(%)} & \thead{sender\ & pcc \ Alg.1 \(%)} & \thead{sender\ only \ Alg.1\ (%)} & \thead{p2 TB\ Alg.2\ (%)} & \thead{sender \& pcc \ Alg.2\ (%)} & \thead{sender\ only \ Alg.2\ (%)} \ \hline \thead{L1D} & 0.041 & 0.111 & 0.111 & 0.111 & 0.111 & 0.111 \ \hline \thead{L2} & 3.586 & 0.111 & 0.111 & 0.111 & 0.111 & 0.111 \ \hline \thead{LLC} & 34.379 & 0.111 & 0.111 & 0.111 & 0.111 & 0.111 \ \hline \end{tabular}} \end{floatrow} \end{table}

\end{document}

enter image description here

Bernard
  • 271,350