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

发布于 2024-08-23 09:00:55 字数 1773 浏览 2 评论 0原文

我正在尝试用 LaTeX 设计一个有点复杂的表格(sidewaystable),有 7 行和 4 列。该表包含文本、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}

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

即,图形需要位于每个单元格中,使得图形上方和下方到相应单元格边界的空间以及左侧和右侧到相应单元格边界的空间是相同的。

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

I am trying to design a somewhat complex table (sidewaystable) with with 7 rows and 4 columns in LaTeX. The table contains text, bibtex-citations, and most importantly figures within cells (currently the figures are jpeg for testing purposes, ultimately I want to change them to PDF). The figures are very closely cropped (on purpose).

I have most of the table layout as I want it to be, but the figures are aligned at the top of the cells! This looks ugly and I need to align them vertically and horizontally within their cells.

I tried several things (parbox, manually defining a new columntype for the array package...) but simply can't figure out how to do it.

Here is how the latex-sourcecode of my table basically looks like (text replaced with mockup text):

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

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.e. the figures need to be in each cell so that the space above and below the figure to the respective cell borders, and left and right to the respective cell borders, is the same.

(I found a few pages about this or related table layout problems but could not understand what to actually do.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

快乐很简单 2024-08-30 09:00:56

您可以使用 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}

You can use the tabularx package (or the array packge) to have all cells vertically aligned. This can start you off:

\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}
涙—继续流 2024-08-30 09:00:56

如果您尝试对齐几个数字,您可以考虑使用 subfig 包而不是 table 环境。它为您提供了更多选择,并且在处理数字时更容易处理。作为介绍,您可以查看 latex wiki,尤其是 浮动、图形和标题 75。实际的包可在 CTAN 站点上找到,并附带附加文档, subfig< /a>.

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

垂直对齐子图 LATEX

此外,它还取决于你的“description1”部分的长度。如果它是一个完整的文本,您可能需要在 minipage 环境中进行。

If you are trying to align a couple of figures you might consider using the subfig package instead of a table environment. It gives you more options and is easier to handle if you are dealing with figures. As an introduction you can take a look at the latex wiki and especially the section Floats, Figures and Captions 75. The actual package is available at the CTAN site with additional documentation, subfig.

This will only give you a different approach and isn't solving your problem right away,
however, reading your question again it looks like you are having something in mind similar to this question:

Vertical alignment of subfigures LATEX

Additionally it depends a little bit on how long your 'description1' part is going to be. If it is a whole text you might want to do it in a minipage environment.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文