I have a table with 2 columns. Left column is text and the right column has an image.
I wanted the row to be aligned at the top. So that the text and the image start at the same horizontal level. Based on this answer I found I can use adjustbox
package to do this.
The above solution works, but only when using pdflatex. When using htlatex on the same tex file the HTML still shows the row to be not aligned. It seems htlatex does not support adjustbox
. If so, any one knows how to do this so that the HTML and the pdf look the same?
Here is the latex file:
\documentclass[]{article}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{adjustbox}
\begin{document}
\begin{longtable}{|p{3in}|p{3in}|}
\\\hline
text text text text
&
\adjustbox{valign=t}{\includegraphics[scale=0.6]{mma_e1}}
\\\hline
\end{longtable}
\end{document}
The commands used are
pdflatex foo.tex
htlatex foo.tex
Texlive 2012 on Linux.
Here is screen shot of the generated PDF and the HTML. You can see they are not the same
note: I need to use longtable
since the table is many pages long. Using tabular
or tabularx
with something as m{}
to center the alignment will not work even though htlatex seems to work with this option. longtable
does not support m{}
alignment of rows, else I could have used this option instead.
appendix
The HTML source code generated by htlatex, if needed, is copied below
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html >
<head><title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
<!-- html -->
<meta name="src" content="index.tex">
<meta name="date" content="2013-05-17 01:15:00">
<link rel="stylesheet" type="text/css" href="index.css">
</head><body
>
<a
id="x1-2r1"></a> <!--l. 8--><div class="longtable"> <table id="TBL-1" class="longtable"
cellspacing="0" cellpadding="0" rules="groups"
><colgroup id="TBL-1-1g"><col
id="TBL-1-1"></colgroup><colgroup id="TBL-1-2g"><col
id="TBL-1-2"></colgroup>
<tr
style="vertical-align:baseline;" id="TBL-1-1-"><td style="white-space:wrap; text-align:left;" id="TBL-1-1-1"
class="td11">
<!--l. 8--><p class="noindent" > </td>
</tr><tr
class="hline"><td><hr></td><td><hr></td></tr><tr
style="vertical-align:baseline;" id="TBL-1-2-"><td style="white-space:wrap; text-align:left;" id="TBL-1-2-1"
class="td11">
<!--l. 9--><p class="noindent" >text text text text </td><td style="white-space:wrap; text-align:left;" id="TBL-1-2-2"
class="td11">
<!--l. 11--><p class="noindent" >
<img
src="index0x.png" alt="PIC" class="graphics" width="180.67683pt" height="180.67683pt" ><!--tex4ht:graphics
name="index0x.png" src="mma_e1.eps"
--> </td>
</tr><tr
class="hline"><td><hr></td><td><hr></td></tr><tr
style="vertical-align:baseline;" id="TBL-1-3-"><td style="white-space:wrap; text-align:left;" id="TBL-1-3-1"
class="td11"> </td>
</tr><tr
style="vertical-align:baseline;" id="TBL-1-4-"><td style="white-space:wrap; text-align:left;" id="TBL-1-4-1"
class="td11"> </td>
</tr><tr
style="vertical-align:baseline;" id="TBL-1-5-"><td style="white-space:wrap; text-align:left;" id="TBL-1-5-1"
class="td11">
<!--l. 13--><p class="noindent" > </td>
</tr><tr
style="vertical-align:baseline;" id="TBL-1-6-"><td style="white-space:wrap; text-align:left;" id="TBL-1-6-1"
class="td11">
<!--l. 13--><p class="noindent" > </td>
</tr><tr
style="vertical-align:baseline;" id="TBL-1-7-"><td style="white-space:wrap; text-align:left;" id="TBL-1-7-1"
class="td11"> </td><td style="white-space:wrap; text-align:left;" id="TBL-1-7-2"
class="td11"></td></tr>
</table></div>
</body></html>
Best Answer
I have found a solution to this. So I post it here in case someone in the future might find it useful.
One needs to add
\Css
to control the vertical alignment of the table rows. htlatex defaults to using<tr style="vertical-align:baseline;"
which is the default in HTML.Adding
\Css{td {vertical-align:middle;}}
to the htlatex configuration file fixes this.(notice, it is
td
in the above, and nottr
). Here is a screen shot of the web pageThe above
\Css
is added after here in the htlatex config file: