【问题标题】:Multirow cells in TeX tablesTeX 表格中的多行单元格
【发布时间】:2011-07-29 23:06:14
【问题描述】:

我正在尝试制作一个与克雷莫纳关于椭圆曲线的书中的first table 非常相似的表格,但有时我希望单元格跨越多行。我不反对使用 LaTeX 包,但我无法弄清楚如何使用可变宽度列,这些列尊重居中列周围的垂直条。

(来自Wikibooks 的这段代码使居中的列看起来是右对齐的

    \begin{tabular*}{0.75\textwidth}{@{\extracolsep{\fill}} | c | c | c | r | }
    \hline
    label 1 & label 2 & label 3 & label 4 \\
    \hline
    item 1  & item 2  & item 3  & item 4  \\
    \hline
    \end{tabular*}

)

任何帮助将不胜感激。

【问题讨论】:

  • 至少对我来说,在回答之前了解确切的问题是有益的。也许您指定一个简单的案例,其中偶尔的多行单元格、可变宽度单元格、居中和垂直条满足或应该满足您的要求。你尝试了哪些乳胶环境/包?
  • 作为参考,有一个特定于 TeX 的 Stack Exchange 站点:tex.stackexchange.com。你可能已经在那里找到了你的问题,而且可能比 StackOverflow 更多的 LaTeX 专家经常光顾它。
  • 我这里没有 LaTeX,所以我无法尝试解决您的问题。但是,我想知道您是否真的需要垂直线。您会注意到大多数专业排版书籍不使用这些,因为您的眼睛可以很好地引导您。有关这方面的更多信息,我建议查看 booktabs 包文档。

标签: latex tex


【解决方案1】:

只需使用 tabular 环境而不是 tabular*,您上面的示例将具有所有居中的列。

为了显示居中的多列和居中的多行(使用包 multirow),我给出了以下示例:

\begin{tabular}{ | c | c | c | r | }
\hline
label 1 & label 2 & label 3 & label 4 \\
\hline
\multicolumn{2}{|c|}{\textbf{Name of the SLA parameter $\pi$}} &
\multicolumn{2}{|c|}{\textbf{Name of the SLA parameter $\pi$}} \\
\hline
\multirow{2}{*}{item 1} & item 2 & item 3 & item 4\\
  & item 2  & item 3  & item 4  \\
\hline
item 1  & item 2  & item 3  & item 4  \\
\hline
\end{tabular}

所有应该居中的列和行都居中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-10
    • 2013-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-03
    • 1970-01-01
    相关资源
    最近更新 更多