You can use p-width
command line option to save width of p
columns:
htlatex filename "xhtml,p-width"
This doesn't support m
columns by default, but you can add support for them easily with this configuration file, my.cfg
:
\Preamble{xhtml,p-width}
\catcode`\:=11
\Configure{halignTD} {}{}
{<}{\HCode{ style="white-space:nowrap; text-align:left;"}}
{-}{\HCode{ style="white-space:nowrap; text-align:center;"}}
{>}{\HCode{ style="white-space:nowrap; text-align:right;"}}
{^}{\HCode{ style="vertical-align:top; white-space:nowrap;"}}
{=}{\HCode{ style="vertical-align:baseline; white-space:nowrap;"}}
{||}{\HCode{ style="vertical-align:middle; white-space:nowrap;"}}
{_}{\HCode{ style="vertical-align:bottom; white-space:nowrap;"}}
{p}{\HCode{ style="white-space:wrap; text-align:left;"}\Protect\a:HColWidth}
{m}{\HCode{ style="white-space:wrap; text-align:left; vertical-align:middle;"}\Protect\a:HColWidth}
{b}{\HCode{ style="white-space:wrap; text-align:left; vertical-align:baseline;"}}
{}
\catcode`\:=12
\begin{document}
\EndPreamble
the magic is in \Protect\a:HColWidth
. Because p-width
option is inserted in the \Preamble
command, you don't need to specify it on the command line anymore. Compile with
htlatex filename my
the result:

old answer, I was wrong
Because tex4ht
redefines lot of things, it seems that we don't have access to dimensions of p
columns. The only way to style this is using custom .cfg file and CSS styles. Your sample creates such HTML
table:
<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><colgroup id="TBL-1-3g"><col
id="TBL-1-3" /></colgroup>
...
important are <col id="TBL-1-2" />
elements, because you can use them for styling columns. The id
is construed as TBL
+ number of table + number of column. So this is second column of first table in the document. Now you can easily style that with such .cfg
file (like hello.cfg
):
\Preamble{xhtml}
\Css{\#TBL-1-2{width:10cm;}}
\Css{\#TBL-1-3{width:5cm;}}
\begin{document}
\EndPreamble
compile it with command:
htlatex filename hello
and the result:

note that you should style tables after your document is done, because if you add new table before some other table which does have styling already, the style would be used for another table!