如何在 LaTeX 中绘制汇总表

如何在 LaTeX 中绘制汇总表

我很难绘制如下所示的表格。

概要表

谁能与我分享类似的相应代码/模板或任何简单的解决方法?

答案1

这里有两种不同的方法,均基于tabularx以确保表格不超过可用的文本宽度,同时允许在具有较长文本的列中换行。

在第一个示例中,我还使用了包\makegapedcells中的功能makecell,在每个单元格内容的上方和下方添加一些空白,以防止文本超出水平线。在第二个示例中,我使用了基于的不同方法booktabs,没有垂直线,只有几条水平线。

在此处输入图片描述

在此处输入图片描述

\documentclass{article}
\usepackage{geometry}
\usepackage{tabularx}
\usepackage{makecell}
\usepackage{caption}
\setcellgapes{4pt}

\usepackage{booktabs}
\begin{document}

\begin{table}[h]
\makegapedcells
    \caption{Table of Summary}
    \label{tos}
    \begin{tabularx}{\textwidth}{|c|c|p{2cm}|c|p{2cm}|X|}
    \hline
        \textbf{Type} & \multicolumn{2}{c|}{\textbf{Methods}} & \textbf{References} & \textbf{Tools} & \textbf{Outcome}\\
    \hline
    \hline
        Ignore Me & Sample & a little bit longer text in this cell & Ignore Me & a little bit longer text in this cell & This cell contains a longer text. This cell contains a longer text. This cell contains a longer text. \\ \cline{3-6}
                  &        & Ignore Me & Ignore Me & Ignore Me &  \\ \cline{3-6}
                  &        & Ignore Me & Ignore Me & Ignore Me &  \\ \cline{2-6}
                  & Sample & Ignore Me & Ignore Me & Ignore Me &  \\ \cline{3-6}
                  &        & Ignore Me & Ignore Me & Ignore Me &  \\
    \hline
    \hline
        Ignore Me & Sample & Ignore Me & Ignore Me & Ignore Me &  \\ \cline{3-6}
                  &        & Ignore Me & Ignore Me & Ignore Me &  \\
    \hline
    \end{tabularx}
\end{table}


\begin{table}[h]
    \caption{Table of Summary}
    \label{tos}
    \begin{tabularx}{\textwidth}{llp{2cm}lp{2cm}X}
    \toprule
        Type & \multicolumn{2}{c}{Methods} & References & Tools & Outcome\\
    \cmidrule(r){1-1} \cmidrule(lr){2-3} \cmidrule(lr){4-4} \cmidrule(lr){5-5} \cmidrule(l){6-6}
        Ignore Me & Sample & a little bit longer text in this cell & Ignore Me & a little bit longer text in this cell & This cell contains a longer text. This cell contains a longer text. This cell contains a longer text. \\ \addlinespace
                  &        & Ignore Me & Ignore Me & Ignore Me &  \\ \addlinespace
                  &        & Ignore Me & Ignore Me & Ignore Me &  \\ \addlinespace
                  & Sample & Ignore Me & Ignore Me & Ignore Me &  \\ \addlinespace
                  &        & Ignore Me & Ignore Me & Ignore Me &  \\
    \midrule
        Ignore Me & Sample & Ignore Me & Ignore Me & Ignore Me &  \\ \addlinespace
                  &        & Ignore Me & Ignore Me & Ignore Me &  \\
    \bottomrule
    \end{tabularx}
\end{table}

\end{document}

xltabular版本允许表格占据多个页面:

\documentclass{article}
\usepackage{geometry}
\usepackage{xltabular}
\usepackage{makecell}
\usepackage{caption}
\setcellgapes{4pt}

\usepackage{booktabs}
\begin{document}


{\makegapedcells
\begin{xltabular}{\textwidth}{|c|c|p{2cm}|c|p{2cm}|X|}
    \caption{Table of Summary}
\label{tos}\\
\hline
    \textbf{Type} & \multicolumn{2}{c|}{\textbf{Methods}} & \textbf{References} & \textbf{Tools} & \textbf{Outcome}\\
\hline
\hline \endfirsthead
        \caption[]{Table of Summary - continued from previous page}\\ % comment out this line if you don't want a repeated caption on the second and following pages.
\hline
    \textbf{Type} & \multicolumn{2}{c|}{\textbf{Methods}} & \textbf{References} & \textbf{Tools} & \textbf{Outcome}\\
\hline
\hline \endhead
        Ignore Me & Sample & a little bit longer text in this cell & Ignore Me & a little bit longer text in this cell & This cell contains a longer text. This cell contains a longer text. This cell contains a longer text. \\ \cline{3-6}
                  &        & Ignore Me & Ignore Me & Ignore Me &  \\ \cline{3-6}
                  &        & Ignore Me & Ignore Me & Ignore Me &  \\ \cline{2-6}
                  & Sample & Ignore Me & Ignore Me & Ignore Me &  \\ \cline{3-6}
                  &        & Ignore Me & Ignore Me & Ignore Me &  \\
    \hline
    \hline
        Ignore Me & Sample & Ignore Me & Ignore Me & Ignore Me &  \\ \cline{3-6}
                  &        & Ignore Me & Ignore Me & Ignore Me &  \\
    \hline
    \end{xltabular}}





    \begin{xltabular}{\textwidth}{llp{2cm}lp{2cm}X}
        \caption{Table of Summary}
    \label{tos}\\
    \toprule
        Type & \multicolumn{2}{c}{Methods} & References & Tools & Outcome\\
    \cmidrule(r){1-1} \cmidrule(lr){2-3} \cmidrule(lr){4-4} \cmidrule(lr){5-5} \cmidrule(l){6-6}
    \endhead
        Ignore Me & Sample & a little bit longer text in this cell & Ignore Me & a little bit longer text in this cell & This cell contains a longer text. This cell contains a longer text. This cell contains a longer text. \\ \addlinespace
                  &        & Ignore Me & Ignore Me & Ignore Me &  \\ \addlinespace
                  &        & Ignore Me & Ignore Me & Ignore Me &  \\ \addlinespace
                  & Sample & Ignore Me & Ignore Me & Ignore Me &  \\ \addlinespace
                  &        & Ignore Me & Ignore Me & Ignore Me &  \\
    \midrule
        Ignore Me & Sample & Ignore Me & Ignore Me & Ignore Me &  \\ \addlinespace
                  &        & Ignore Me & Ignore Me & Ignore Me &  \\
    \bottomrule
    \end{xltabular}


\end{document}

答案2

\begin{tabular}{|*{6}{l|}}
\hline
Type &\multicolumn{2}{|c|}{ Methods} &   Reference & Tools & Outcome\\
\hline
\hline
Ignore Me & Sample & Ignore Me & Ignore Me & Ignore Me & \\\cline{3-6}
 &  & Ignore Me & Ignore Me & Ignore Me & \\\cline{3-6}
 &  & Ignore Me & Ignore Me & Ignore Me & \\\cline{3-6}
 & Sample & Ignore Me & Ignore Me & Ignore Me & \\\cline{2-6}
 &  & Ignore Me & Ignore Me & Ignore Me & \\
\hline
\hline
Ignore Me & Sample & Ignore Me & Ignore Me & Ignore Me & \\\cline{3-6}
 &  &  &  &  & \\
\hline
\end{tabular}

表格

相关内容