I am trying to create a longtable where the first column contains only images. The longtable is defined as (with only one row):
\begin{longtable}{m{0.2\linewidth} m{0.7\linewidth}}
\hline
\includegraphics[keepaspectratio,width=\linewidth]{RectSolid.eps} & $\!\begin{aligned}
A &= b\cdot{}h\\
P &= 2(b+h)\\
y &= \dfrac{h}{2}\\
I_y &= \dfrac{1}{12}b\cdot{}h^3
\end{aligned}$
\\\hline
\end{longtable}
The result I get is (the image is tightly cropped, with no white-space padding):
It seems as though the image's baseline is at its bottom, so that it rests at the midpoint of the row. Or perhaps longtable expects text and therefore places the basepoint not at the midpoint, but at "midpoint – textHeight". Regardless, this is clearly not good enough.
I've seen at Vertical aligning in longtable environment the suggestion of using \raisebox{-\height}{\includegraphics{....}}
(or \normalbaselineskip-\height
or, on my own 0.5\height
), but the results aren't much better:
Another suggestion given in a comment by @egreg in that link is the use of adjustbox
, but I unfortunately can't even see if that'd work for me because I'm forced to use a .cls file given by my university which doesn't compile with that package (the university's .cls file is garbage, using a bunch of depreciated packages).
So the question is: is it possible to vertically align figures in a longtable without the adjustbox
package? It doesn't need to be the longtable
package, but the table needs to span multiple pages. So if there's some other package that pulls that off, I'm willing to give it a try.
EDIT 1:
People have asked for a MWE, so here it is. I placed it in the public directory of my Dropbox and it can be downloaded here. I can't simply put the code because the \documentclass
is given by my university's .cls file (ThesisPKKN2, which is actually a modification of the original I created to use subcaption
instead of the outdated subfigure
package).
EDIT 2:
The MWE linked above actually uses Andrew Swann's idea of \vcenter
, but even though it clearly works wonders in the example he presents, in my case this is the result:
\begin{longtable}{m{0.2\linewidth} m{0.7\linewidth}}
\hline
$\vcenter{\includegraphics[keepaspectratio,width=\linewidth]{RectSolid.eps}}$ & $\!\begin{aligned}
A &= b\cdot{}h\\
P &= 2(b+h)\\
y &= \dfrac{h}{2}\\
I_y &= \dfrac{1}{12}b\cdot{}h^3
\end{aligned}$
\\\hline
\end{longtable}
I'd say this is the best result so far, but there still seems to be more space below than above the image.
EDIT 3:
Here is the MWE code itself.
\documentclass[dissertacao,brazil]{ThesisPKKN2}
\usepackage{array}
\usepackage{amsmath}
\usepackage{epstopdf}
\usepackage{etoolbox}
\usepackage{fixltx2e}
\usepackage{longtable}
\graphicspath{{./figures/}} % graphicx
\begin{document}
\begin{longtable}{m{0.2\linewidth} m{0.7\linewidth}}
\hline
$\vcenter{\includegraphics[keepaspectratio,width=\linewidth]{RectSolid.eps}}$ & $\!\begin{aligned}
A &= b\cdot{}h\\
P &= 2(b+h)\\
y &= \dfrac{h}{2}\\
I_y &= \dfrac{1}{12}b\cdot{}h^3
\end{aligned}$
\\\hline
\end{longtable}
\end{document}
EDIT 4:
As commented, I just realized this is an issue using GIMP, not with TeX. My trimmed image is getting massive padding around it which is what is causing the image to be off-center. For whatever reason, this image
when exported into .eps and placed in TeX becomes
Regardless, this is a GIMP issue, not a TeX issue. Nevermind. That being said, Swann's \vcenter
method actually works like a charm.
Best Answer
You can use
$\vcenter{...}$
: