开发者

Vertically align figures in table cells?

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.\ cerevis开发者_开发知识库iae, 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.)


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}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜