alex_bn_lee

导航

【650】LaTeX表格合并实现

LaTex制作表格之合并单元格

latex 表格如何精细控制行高,行距,行与行之间的距离

Latex 表格 行合并,列合并,控制行间距 单元格宽度

Tables Generator

  在制作LaTex表格的时候,常常需要合并行和列,本文介绍的是使用 multirow 包里面的命令完成合并行列的方法。

  需要先导入以下库:

\usepackage{multirow}

  举例:

\begin{table * }
% \usepackage{multirow}
\center
\begin{tabular}{|c|c|c|c|c|}
  \hline  % horizontal line
  \multirow{ 2 }{ * }{ 1 \&  2 } & \multicolumn{ 2 }{l|}{  3 \&  4 } &  5 &  6 \\  % end line
  \cline{ 2 - 5 }  % short partial horizontal lines  from column  2 to column  5
   &  7 &  8 &  9 &  10 \\  % first cell  is occupied by the multirow
  \hline
  \hline
  $ s_{ 1 } $ &  2 &  3 &  4 &  5 \\
  $ s_{ 2 } $ &  2 &  3 &  4 &  5 \\
  \hline
  \hline
  $ s_{ 3 } $ &  2 &  3 &  4 &  5 \\ 
  $ s_{ 4 } $ &  2 &  3 &  4 &  5 \\
  \hline
\end{tabular}
\end{table * }

  效果 

\begin{table}[h]
    \caption{Optimization summary.}
    \label{tab:summary}
    \begin{tabular}{cccc}
        \toprule
        \multirow{ 2 }{ * }{Design} & \multicolumn{ 2 }{c}{Problem size} & \multirow{ 2 }{ * }{CPU time(s)} \\
        \cline{ 2 - 3 }
        & Binary variables & Constraints\\
        \midrule
        OM1 &  199 &  13 , 017 &  000 \\
        OM2 &  199 &  1 , 525 &  000 \\
        \bottomrule
    \end{tabular}
    \label{tab:my_label}
\end{table}

  效果(后面有改进版)

  举例:

\begin{table}[h]
    \caption{Optimization summary.}
    \centering
    \vspace{2mm}
    \begin{tabular}{ccccccccc}
        \toprule
        \multirow{2}{*}{Model Name} & \multicolumn{4}{c}{Building Roof} & \multicolumn{4}{c}{Building}\\
        \cline{2-9}
        & Precision & Recall & $F_1$ & IoU & Precision & Recall & $F_1$ & IoU\\
        \midrule
        FCN-8s \cite{long2015fully}             & 69.83   & 69.83   & 69.83   & 69.83    & 69.83   & 69.83    & 69.83   & 69.83\\
        U-Net \cite{ronneberger2015u}           & 69.83   & 69.83   & 69.83   & 69.83    & 69.83   & 69.83    & 69.83   & 69.83\\
        Res-U-Net \cite{xu2018building}         & 69.83   & 69.83   & 69.83   & 69.83    & 69.83   & 69.83    & 69.83   & 69.83\\
        SegNet \cite{badrinarayanan2017segnet}  & 69.83   & 69.83   & 69.83   & 69.83    & 69.83   & 69.83    & 69.83   & 69.83\\
        DeepLabV3+ \cite{chen2018encoder}       & 69.83   & 69.83   & 69.83   & 69.83    & 69.83   & 69.83    & 69.83   & 69.83\\
        DeConvNet \cite{noh2015learning}        & 69.83   & 69.83   & 69.83   & 69.83    & 69.83   & 69.83    & 69.83   & 69.83\\
        Our Model                               & 69.83   & 69.83   & 69.83   & 69.83    & 69.83   & 69.83    & 69.83   & 69.83\\
        \bottomrule
    \end{tabular}
    \label{tab:my_label}
\end{table}

  效果:

上面表格的问题在于两行标题栏距离太近,通过下面解决,也可以参考网站 https://www.tablesgenerator.com (Booktabs table style)

修改代码:

% Please add the following required packages to your document preamble:
% \usepackage{booktabs}
% \usepackage{multirow}

\begin{table}[h]
    \caption{Optimization summary.}
    \label{tab:summary}
    \begin{tabular}{cccc}
        \toprule
        \multirow{2}{*}{Design} & \multicolumn{2}{c}{Problem size} & \multirow{2}{*}{CPU time(s)} \\
        \cmidrule{2-3}
        & Binary variables & Constraints\\
        \midrule
        OM1 & 199 & 13,017 & 78.7 \\
        OM2 & 199 & 1,525 & 13.8 \\
        \bottomrule
    \end{tabular}
    \label{tab:my_label}
\end{table}

 效果:(更协调了一些,目前最优

  • toprule:最上面的线(粗)
  • cmidrule:标题中间的线(细)
  • midrule:中间的线(中)
  • bottomrule:最下面的线(粗)

 

 

 

  添加表格注释,参考:Latex如何在表格下方显示注脚_小白皮皮-程序员宅基地_latex 表格下方注释

  导入以下库:

\usepackage{threeparttable}

  举例:

\begin{table}[h]
    \centering
    \caption{Quantitative comparison of four conventionally used metrics obtained  from the segmentation results  by FCN-8s, U-Net, Res-U-Net, SegNet, DeepLabV3+, DeConvNet, and the proposed model,  where the values  in bold format are the highest numbers  for corresponding metrics.}
   
    \vspace{2mm}
    \begin{threeparttable} % 增加部分
    \begin{tabular}{ccccccccc}
        \toprule
        \multirow{2}{*}{Model Name} & \multicolumn{4}{c}{Building Roof} & \multicolumn{4}{c}{Building}\\
        \cline{2-9}
        & Precision & Recall & $F_1$ & IoU & Precision & Recall & $F_1$ & IoU\\
        \midrule
        FCN-8s \cite{long2015fully}             & 69.83   & 69.83   & 69.83   & 69.83    & 69.83   & 69.83    & 69.83   & 69.83\\
        U-Net \cite{ronneberger2015u}           & 69.83   & 69.83   & 69.83   & 69.83    & 69.83   & 69.83    & 69.83   & 69.83\\
        Res-U-Net \cite{xu2018building}         & 69.83   & 69.83   & 69.83   & 69.83    & 69.83   & 69.83    & 69.83   & 69.83\\
        SegNet \cite{badrinarayanan2017segnet}  & 69.83   & 69.83   & 69.83   & 69.83    & 69.83   & 69.83    & 69.83   & 69.83\\
        DeepLabV3+ \cite{chen2018encoder}       & 69.83   & 69.83   & 69.83   & 69.83    & 69.83   & 69.83    & 69.83   & 69.83\\
        DeConvNet \cite{noh2015learning}        & 69.83   & 69.83   & 69.83   & 69.83    & 69.83   & 69.83    & 69.83   & 69.83\\
        Our Model                               & 69.83   & 69.83   & 69.83   & 69.83    & 69.83   & 69.83    & 69.83   & 69.83\\
        \bottomrule
    \end{tabular}
    \label{tab:my_label}
    \begin{tablenotes}  %增加部分
        \item The bolded numbers indicate the largest number  in the column, easier to find  out which one performs better  in this format.
     \end{tablenotes}  %增加部分
    \end{threeparttable}  %增加部分
\end{table}

   效果:

 


9-Nov-2023

ref: Tables Generator

\begin{table*}[!t]
    %\renewcommand{\arraystretch}{1.3}
    \caption{Information on GPS trajectory dataset.}
    \centering
    \begin{tabular}{c|cccc}
        \toprule
        
        % this part is the header
        \begin{tabular}[c]{@{}c@{}}Transportation \\mode\end{tabular} &
        \begin{tabular}[c]{@{}c@{}}Number of \\residential complexes\end{tabular} & 
        \begin{tabular}[c]{@{}c@{}}Distance \\(km)\end{tabular} & 
        \begin{tabular}[c]{@{}c@{}}Duration \\(hour)\end{tabular} & 
        \begin{tabular}[c]{@{}c@{}}Number of \\trajectories\end{tabular}\\
        % this part is the header
        
        \midrule
        Walking & 376   & 12,295 & 6,630  & 61,356 \\
        Cycling & 932   & 44,512 & 13,516 & 163,200 \\
        \midrule
        Total   & 1,308 & 56,807 & 20,146 & 224,556 \\
        \bottomrule
    \end{tabular}
    \label{

posted on 2021-08-28 19:48  McDelfino  阅读(6891)  评论(1编辑  收藏  举报