垂直对齐表格单元格中的数字?
我正在尝试用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
tabularx
包(或array
包)使所有单元格垂直对齐。这可以让你开始:You can use the
tabularx
package (or thearray
packge) to have all cells vertically aligned. This can start you off:如果您尝试对齐几个数字,您可以考虑使用
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 atable
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.