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:


text text text text

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 enter image description here

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"  
<html > 
<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"> 
 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 
 style="vertical-align:baseline;" id="TBL-1-1-"><td  style="white-space:wrap; text-align:left;" id="TBL-1-1-1"  
<!--l. 8--><p class="noindent" >                                         </td>
 style="vertical-align:baseline;" id="TBL-1-2-"><td  style="white-space:wrap; text-align:left;" id="TBL-1-2-1"  
<!--l. 9--><p class="noindent" >text text text text                                         </td><td  style="white-space:wrap; text-align:left;" id="TBL-1-2-2"  
<!--l. 11--><p class="noindent" >
src="index0x.png" alt="PIC" class="graphics" width="180.67683pt" height="180.67683pt" ><!--tex4ht:graphics  
name="index0x.png" src="mma_e1.eps"  
-->    </td>
 style="vertical-align:baseline;" id="TBL-1-3-"><td  style="white-space:wrap; text-align:left;" id="TBL-1-3-1"  
class="td11">                                         </td>
 style="vertical-align:baseline;" id="TBL-1-4-"><td  style="white-space:wrap; text-align:left;" id="TBL-1-4-1"  
class="td11">                                         </td>
 style="vertical-align:baseline;" id="TBL-1-5-"><td  style="white-space:wrap; text-align:left;" id="TBL-1-5-1"  
<!--l. 13--><p class="noindent" >                                         </td>
 style="vertical-align:baseline;" id="TBL-1-6-"><td  style="white-space:wrap; text-align:left;" id="TBL-1-6-1"  
<!--l. 13--><p class="noindent" >                                         </td>
 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"  


1 Answer 1


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 not tr). Here is a screen shot of the web page

enter image description here

The above \Css is added after here in the htlatex config file:


\Css{td {vertical-align: middle;}}  %add here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .