关于表格的问题

关于表格的问题

我需要一些tableLaTeX 代码。如您所见,我的 LaTeX 代码如下

\setlength{\extrarowheight}{7.6pt}
\begin{footnotesize}
\begin{tabular}{l|m{7cm}}
\hline
\hline
Workloads & Applications  \\
\hline
\hline
mix-1 & mcf, libquantum, \\
\hline
mix-2 & sphinx3, soplex, \\
\hline
mix-3 & omnetpp, xalancbmk, \\
\hline
\hline
\end{tabular}
\end{footnotesize}

其实我看不懂array这个包,我指的是它m{2.5cm}的使用方法,我想让右侧的文本像左侧一样垂直居中对齐。

你能帮助我吗?其他网站上的一些解释让我感到困惑,因为我不是 LaTeX 专家。

答案1

就单元格内容垂直居中而言tabular,您无需设置\extrarowheight。但是,当您的右侧列内容较多(即较长)时,使用m{<len>}(其中是任何可识别的 TeX 长度)会很有用。<len>

如果您希望在条目周围增加更多垂直填充,请进行修改\arraystretch。它提供了行被拉伸/扩展的因素:

在此处输入图片描述

\documentclass{article}
\usepackage{array}% http://ctan.org/pkg/array
\begin{document}
\renewcommand{\arraystretch}{2.5}% array stretch factor
\begin{footnotesize}
\begin{tabular}{l|p{7cm}}
  \hline
  \hline
  Workloads & Applications  \\
  \hline
  \hline
  mix-1 & mcf, libquantum, \\
  \hline
  mix-2 & sphinx3, soplex, \\
  \hline
  mix-3 & omnetpp, xalancbmk, \\
  \hline
  \hline
\end{tabular}
\end{footnotesize}
\end{document}

有关单元格条目填充tabular(水平和垂直)的更多信息,请参阅表格中的列和行填充

答案2

我认为你的问题是你的前提。如果你包括\usepackage{array}这个编译。此外,你应该将移动\setlength{\extrarowheight}{7.6pt}到一个组内(除非你想让它适用于全部表格),您将获得:

在此处输入图片描述

\documentclass{article}
\usepackage{array}
\begin{document}
\begin{footnotesize} \setlength{\extrarowheight}{7.6pt}
\begin{tabular}{l|m{7cm}}
\hline
\hline
Workloads & Applications  \\
\hline
\hline
mix-1 & mcf, libquantum, \\
\hline
mix-2 & sphinx3, soplex, \\
\hline
mix-3 & omnetpp, xalancbmk, \\
\hline
\hline
\end{tabular}
\end{footnotesize}
\end{document}

如果你希望两列垂直居中,那么你必须使用

\begin{tabular}{m{1.5cm}|m{7cm}}

得出以下结果。数据上方的额外垂直空间来自您的设置\extrarowheight

在此处输入图片描述

相关内容