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.)
To place an item at the top or bottom of its cell, insert the "VALIGN=" attribute within the code for that cell. To vertically align an entire row (e.g., placing all data in that row at the tops of the cells), insert the "VALIGN=" attribute within the code for that row.
Answer: Use the CSS vertical-align Property You can align an image vertically center inside a <div> by using the CSS vertical-align property in combination with the display: table-cell; on the containing div element.
Select the text that you want to center. in the Page Setup group, and then click the Layout tab. In the Vertical alignment box, click Center. In the Apply to box, click Selected text, and then click OK.
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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With