如何在Latex中创建包含合并标头的3列表

时间:2015-11-18 20:41:06

标签: latex

Model Table

这是我想在Latex中做的表的一个例子。此表是一个应该如下所示的集合的一部分:

Complete set of tables

我试图使用通常的表格和其他变体,但通常表格会重叠并占据整个页面。

实现它的示例代码是什么?

1 个答案:

答案 0 :(得分:2)

我不完全确定你的问题是什么:

  • 如果需要合并多个单元格,则必须使用\multicolumn - 命令。
  • 如果您想并排放置两张桌子,可以合并几个小型件
  • 如果您希望单元格的内容包含换行符,请尝试将内容嵌入parbox / minipage

以下示例演示了上述所有问题的解决方案:

\documentclass[a4paper]{article}
\usepackage[a4paper,includeheadfoot,margin=1.54cm]{geometry}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\begin{document}
\begin{center}
\begin{minipage}[t]{\textwidth}
    \begingroup
    \parfillskip=0pt

    \begin{minipage}[t]{0.49\textwidth}

            \begin{tabular}{| c | c | c |}
            \hline
            \multicolumn{3}{|c|}{Archae}\\
            \hline
            \begin{minipage}{2cm}{\centering structures with non-immunoglobin}\end{minipage} & 
            \begin{minipage}{2cm}{\centering structures with Immunoglobin}\end{minipage}  & 
            \begin{minipage}{2cm}{\centering total of proteins found}\end{minipage} \\
            \hline
            1 & 16 & 17 \\
            \hline
            \end{tabular}
    \end{minipage}%
    \hfill
    \begin{minipage}[t]{0.49\textwidth}
            \begin{tabular}{| c | c | c |}
            \hline
            \multicolumn{3}{|c|}{Bacteria}\\
            \hline
            \begin{minipage}{2cm}{\centering structures with non-immunoglobin}\end{minipage} & 
            \begin{minipage}{2cm}{\centering structures with Immunoglobin}\end{minipage}  & 
            \begin{minipage}{2cm}{\centering total of proteins found}\end{minipage} \\
            \hline
            11 & 16 & 27 \\
            \hline
            \end{tabular}
    \end{minipage}%
    \par\endgroup
\end{minipage}
\end{center}

\end{document}

输出看起来像这样 enter image description here

<强>更新 您可能必须调整包含parbox的单元格的垂直间距。要了解如何执行此操作,请阅读此Stackoverflow-question或此stackexchange-question

相关问题