如何在特定单元格内创建包含合并行和项目符号的表格?

如何在特定单元格内创建包含合并行和项目符号的表格?

我想在 Latex 中创建这样的表格: 示例表

我无法弄清楚如何合并第 1 列和第 2 列中的单元格以及如何在第 3 列中添加项目符号。有人可以帮忙弄清楚如何去做吗?

到目前为止我能想到的办法是:

\documentclass[a4paper]{article}
\usepackage{multirow}
\usepackage{makecell}
% From https://tex.stackexchange.com/a/150650/85834
\newcommand{\tabitem}{~~\llap{\textbullet}~~}
\begin{document}
\begin{center}
    \begin{tabular}{| c | c | c |}
        \hline
        \multirow{2}{2.5cm}{Deep Learning} & \ \makecell{Medical Image \\ Analysis} &
    \tabitem Built a deep learning model using Mask R-CNN for instance segmentation of nuclei images\\\cline{2-3}
                                           & \ \makecell{Image \\ Classification}\\\hline
        \multirow{2}{*}{Time Series}       & \ \makecell{Walmart Sales \\
        Forecasting}                       & \ \tabitem Built a deep learning model using Mask R-CNN
        for instance segmentation of nuclei images \\
                                           & \ \makecell{Rossmann Sales \\ Forecasting}\\\hline
    \end{tabular}
\end{center}
\label{tab:multicol}
\end{document}

答案1

使用该enumitem包,您可以定义自己的itemize类似环境,并将其用于表格单元格内的列表。tabularx另外还可以帮助自动使表格跨越文本宽度:

\documentclass[a4paper]{article}
\usepackage{multirow}
\usepackage{array}
\usepackage{tabularx}
\usepackage{enumitem}
\newlist{tabitemize}{itemize}{1}
\setlist[tabitemize]{nosep,
                  topsep= 0pt,
                  partopsep=0pt,
                  leftmargin= *,
                  label=\textbullet,
                  before=\vspace{0.3\baselineskip},
                  after=\vspace{-\baselineskip}
                  }
\renewcommand\tabularxcolumn[1]{m{#1}}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}


\begin{document}
\begin{tabularx}{\textwidth}{| M{1.5cm} | M{2.25cm} | X |}
  \hline
  \multirow{3}{1.5cm}{\centering Deep Learning} 
  & Medical Image Analysis 
  & \begin{tabitemize} 
       \item Built a deep learning model using Mask R-CNN for instance segmentation of nuclei images 
       \item another long line of text
    \end{tabitemize}\\ 
  \cline{2-3}
  & Image \newline Classification 
  & \begin{tabitemize} 
       \item first long line of text 
       \item another long line of text 
    \end{tabitemize}\\ 
  \hline
  \multirow{3}{1.5cm}{\centering Time Series} 
  & Walmart Sales Forecasting 
  & \begin{tabitemize} 
       \item long text 
    \end{tabitemize} \\ 
  \cline{2-3}
  & Rossman Sales Forecast 
  & \begin{tabitemize} 
       \item long text 
    \end{tabitemize} \\
  \hline
\end{tabularx}
\end{document}

在此处输入图片描述

我个人建议采用不同的设计:

在此处输入图片描述

在这里,我删除了所有垂直线,并用来自booktabs。此外,我将表格单元格的所有条目对齐到顶部,并添加了一些垂直空白以引导视线。

\documentclass[a4paper]{article}
\usepackage{tabularx}
\usepackage{enumitem}
\newlist{tabitemize}{itemize}{1}
\setlist[tabitemize]{nosep,
                  topsep= 0pt,
                  partopsep=0pt,
                  leftmargin= *,
                  label=\textbullet,
                  before=\vspace{-0.6\baselineskip},
                  after=\vspace{-\baselineskip}
                  }
\usepackage{booktabs}

\begin{document}
\begin{tabularx}{\textwidth}{ p{1.5cm}  p{2.25cm}  X }
  \toprule
  Deep \newline Learning 
  & Medical Image Analysis 
  & \begin{tabitemize} 
       \item Built a deep learning model using Mask R-CNN for instance segmentation of nuclei images 
       \item another long line of text
    \end{tabitemize}\\ 
     \addlinespace[2ex]
  & Image \newline Classification 
  & \begin{tabitemize} 
       \item first long line of text 
       \item another long line of text 
    \end{tabitemize}\\ 
  \midrule
  Time \newline Series
  & Walmart Sales Forecasting 
  & \begin{tabitemize} 
       \item long text 
    \end{tabitemize} \\ 
     \addlinespace[2ex]
  & Rossman Sales Forecast 
  & \begin{tabitemize} 
       \item long text 
    \end{tabitemize} \\
  \bottomrule
\end{tabularx}
\end{document}

相关内容