垂直对齐表格单元格中的数字?

时间:2010-03-04 11:41:44

标签: latex

我正在尝试设计一个有点复杂的表(sidewaystable),在LaTeX中有7行和4列。该表包含文本,bibtex-citations,最重要的是单元格内的数字(目前这些数字是用于测试目的的jpeg,最终我想将它们更改为PDF)。这些数字非常紧密(有目的)。

我有大部分的表格布局,但是数字在单元格的顶部对齐!这看起来很难看,我需要在它们的单元格中垂直和水平对齐它们。

我尝试了几件事(parbox,为数组包手动定义一个新的columntype ......),但根本无法弄清楚如何去做。

以下是我的表的latex-sourcecode基本上是什么样的(文本替换为模型文本):

    % THE TABLE
\begin{sidewaystable}\footnotesize
   \begin{tabular}{| p{3cm} | c | p{6cm} | p{4cm} |}
    \hline
    column1description & column2description & TypeOfOrganism & column4description\\ \hline
    \hline
    Diagram1title & \includegraphics[scale=0.25]{vector_figures/mockup_001.jpg} & description1 & {\em S.\ cerevisiae, E.\ coli}\\ \hline
    Diagram2title & \includegraphics[scale=0.25]{vector_figures/mockup_002.jpg} & description2 & {\em S.\ cerevisiae, E.\ coli}\\ \hline
    Diagram3title & \includegraphics[scale=0.25]{vector_figures/mockup_003.jpg} & description3 & {\em S.\ cerevisiae, E.\ coli}\\ \hline
    Diagram4title & \includegraphics[scale=0.25]{vector_figures/mockup_004.jpg} & description4 & {\em S.\ cerevisiae}\\ \hline
    Diagram5title & \includegraphics[scale=0.25]{vector_figures/mockup_005.jpg} & description5 & {\em S.\ cerevisiae}\\ \hline
    Diagram6title & \includegraphics[scale=0.25]{vector_figures/mockup_006.jpg} & description6 & {\em S.\ cerevisiae}\\ \hline

  \end{tabular}

  \caption[Diagrams and their descriptions]{\textbf{ Diagrams and their descriptions} Some diagrams with interesting descriptions}\label{tab:table2}.

\end{sidewaystable}

如果有人可以给我一些关于如何在其细胞内垂直和水平对齐数字的信息,我将非常感激。

即。数字需要位于每个单元格中,以使图形上方和下方的空间与相应的单元格边界相对应,并且左右各自的单元格边界相同。

(我发现了一些关于这个或相关表格布局问题的页面,但无法理解实际做什么。)

2 个答案:

答案 0 :(得分:1)

您可以使用tabularx包(或array包)将所有单元格垂直对齐。这可以让你开始:

\usepackage{tabularx}
\begin{document}

\renewcommand{\tabularxcolumn}[1]{>{\arraybackslash}m{#1}}
\begin{tabularx}{\textwidth}{XXXX}
    \hline
    column1description & column2description & TypeOfOrganism & column4description\\ \hline
    \hline
    Diagram1title & the graphics & I would be very thankful if someone
    could give me some information on how to align the figures vertically
    as well as horizontally within their cells.I would be very thankful if someone could give me some information on how to align the figures vertically as well as horizontally within their cells. & {\em S.\ cerevisiae, E.\ coli}\\ 
    \hline\\
    Diagram1title & the graphics & I would be very thankful if someone
    could give me some information on how to align the figures vertically
    as well as horizontally within their cells.I would be very thankful if
    someone could give me some information on how to align the figures
    vertically as well as horizontally within their cells. & {\em S.\
    cerevisiae, E.\ coli}\\ 
    \hline
\end{tabularx}

\end{document}

答案 1 :(得分:1)

如果您尝试对齐几个数字,可以考虑使用subfig包而不是table环境。它为您提供了更多选择,如果您处理数字更容易处理。作为简介,您可以查看latex wiki,尤其是Floats, Figures and Captions 75部分。 CTAN网站上提供了实际的软件包以及其他文档subfig

这只会给你一个不同的方法,而不是马上解决你的问题, 然而,再次阅读你的问题看起来你有类似于这个问题的想法:

Vertical alignment of subfigures LATEX

另外,它取决于你的'description1'部分将会有多长。如果是全文,您可能希望在minipage环境中执行此操作。