【问题标题】:Vertically align figures in table cells?垂直对齐表格单元格中的数字?
【发布时间】:2011-01-23 15:35:25
【问题描述】:

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

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

我尝试了几件事(parbox,为数组包手动定义一个新的列类型......)但根本不知道该怎么做。

这是我的表格的乳胶源代码的基本外观(文本替换为模型文本):

    % 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}

如果有人能给我一些关于如何在单元格内垂直和水平对齐数字的信息,我将非常感激。

即数字需要在每个单元格中,以便数字上方和下方到相应单元格边界的空间以及左右到相应单元格边界的空间相同。

(我找到了几页关于这个或相关表格布局问题的页面,但不明白该怎么做。)

【问题讨论】:

    标签: latex


    【解决方案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}
    

    【讨论】:

      【解决方案2】:

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

      这只会为您提供不同的方法,并不能立即解决您的问题, 但是,再次阅读您的问题,您的想法似乎与此问题类似:

      Vertical alignment of subfigures LATEX

      此外,它还取决于您的“description1”部分将持续多长时间。如果是整个文本,您可能希望在 minipage 环境中进行。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-04-03
        • 1970-01-01
        • 1970-01-01
        • 2014-08-18
        • 1970-01-01
        • 2013-10-20
        相关资源
        最近更新 更多