COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### tex4ht and tables

• Email
• Follow

Hi,

I am trying to convert a latex document into HTML. The document includes
several tables which should all have one of two layouts (columns
width). Unfortunately, when I convert my document with tex4ht, the
layouts of the tables are not specified in the html file and are left to
the browser. Said another way,in the following command

\begin{tabular}[pos]{cols}
column 1 entry & column 2 entry ... & column n entry \\
.
.
.
\end{tabular}

the cols specification is not retained.

At the moment I have achieved my goal by defining two new commands

which are asserted just before \begin{tabular} (one of the two commands,
depending on the desired layout).
Since they do nothing, they do not disturb LaTeX or pdfLaTeX, but now I
can use them in the .cfg file to change the tex4ht hooks of the tabular
environment:

\Configure{tabular}
{\HCode{<table class="tabular" cellspacing="0pt"
<colgroup class="maintable">
<col width="160">
<col width="500">
</colgroup>}}
{\HCode{</table>}}
{\HCode{<tr valign="baseline" class="maintablerow">}}
{\HCode{</tr>}}
{\HCode{<td  align="left" class="maintableentry">}}
{\HCode{</td>}} }

Admittedly this is not very straightforward. I have discovered tex4ht
just two day ago and I am wondering if there is a simpler method.

Thank you for any suggestion.
Fede


 0
Reply beffa (6) 2/13/2004 3:08:59 PM

See related articles to this posting

Federico Beffa wrote:
>
> Hi,
>
> I am trying to convert a latex document into HTML. The document includes
>   several tables which should all have one of two layouts (columns
> width). Unfortunately, when I convert my document with tex4ht, the
> layouts of the tables are not specified in the html file and are left to
> the browser. Said another way,in the following command
>
>  \begin{tabular}[pos]{cols}
>  column 1 entry & column 2 entry ... & column n entry \\
>  .
>  .
>  .
>  \end{tabular}
>
> the cols specification is not retained.
> ...
> I have discovered tex4ht
> just two day ago and I am wondering if there is a simpler method.
>
> Thank you for any suggestion.
> Fede
>

Try TtH:

http://hutchinson.belmont.ma.us/tth/

Ian Hutchinson.


 0
Reply hutch2980 (34) 2/14/2004 9:57:56 PM

On Sat, 14 Feb 2004, Ian Hutchinson wrote:

> Federico Beffa wrote:
> >
> > Hi,
> >
> > I am trying to convert a latex document into HTML. The document includes
> >   several tables which should all have one of two layouts (columns
> > width). Unfortunately, when I convert my document with tex4ht, the
> > layouts of the tables are not specified in the html file and are left to
> > the browser. Said another way,in the following command
> >
> >  \begin{tabular}[pos]{cols}
> >  column 1 entry & column 2 entry ... & column n entry \\
> >  .
> >  .
> >  .
> >  \end{tabular}
> >
> > the cols specification is not retained.
>  > ...
> > I have discovered tex4ht
> > just two day ago and I am wondering if there is a simpler method.
> >
> > Thank you for any suggestion.
> > Fede
> >
>
> Try TtH:
>
> http://hutchinson.belmont.ma.us/tth/
>
> Ian Hutchinson.
>
>

Thank you for your suggestion. I have tried Tth, and it does a good
job with tabular. Unfortunately, it has problems with \newlength, and
when LaTeX macros get redefined.

I am happy with the very dynamic configurability and capability of
tex4ht. The one point which is disturbing me, is that when the width of
a column of a tabular environment is specified with p{width}, this is
not reproduced in the HTML output. This seems to me a basic need, but I
I were happy to find a simple way to achieve this with tex4ht.

Fede


 0
Reply beffa (6) 2/15/2004 1:27:25 PM

>    several tables which should all have one of two layouts (columns
> width). Unfortunately, when I convert my document with tex4ht, the
> layouts of the tables are not specified in the html file and are left to
> the browser.

I modified tex4ht (in the bug fixes distribution) to allow for width
specifications of p-columns through the command line option p-width'.

This command line option activates a configuration similar to the
following ones.

\Configure{HColWidth}
{\HCode{ style="width:\HColWidth"}}

\Configure{HColWidth}
{\HCode{ style="width:
\ifnum \HCol=1 160\fi
\ifnum \HCol=3 500\fi
"}}

Try the above examples with, for instance, the following source under
different font sizes in the browser.

\begin{tabular}{p{2cm}cp{3cm}}
1 2 3 1 2 3 1 2 3 1 2 3 & x & 1 2 3 1 2 3 1 2 3 1 2 3
\end{tabular}

The configuration provided through the command line option p-width'
takes to some degree into account the size of fonts in use within the
HTML displays.  Yet, not all the browsers react properly to the size
changes.

-eitan


 0
Reply gurari (142) 2/15/2004 10:28:58 PM

On 15 Feb 2004, Eitan Gurari wrote:

>
> >    several tables which should all have one of two layouts (columns
> > width). Unfortunately, when I convert my document with tex4ht, the
> > layouts of the tables are not specified in the html file and are left to
> > the browser.
>
> I modified tex4ht (in the bug fixes distribution) to allow for width
> specifications of p-columns through the command line option p-width'.
>
> This command line option activates a configuration similar to the
> following ones.
>
>    \Configure{HColWidth}
>       {\HCode{ style="width:\HColWidth"}}
>
>    \Configure{HColWidth}
>       {\HCode{ style="width:
>                       \ifnum \HCol=1 160\fi
>                       \ifnum \HCol=3 500\fi
>        "}}
>
> Try the above examples with, for instance, the following source under
> different font sizes in the browser.
>
>    \begin{tabular}{p{2cm}cp{3cm}}
>    1 2 3 1 2 3 1 2 3 1 2 3 & x & 1 2 3 1 2 3 1 2 3 1 2 3
>    \end{tabular}
>
> The configuration provided through the command line option p-width'
> takes to some degree into account the size of fonts in use within the
> HTML displays.  Yet, not all the browsers react properly to the size
> changes.
>
> -eitan
>

Thank you for the help! I have installed the new release (bugfix) and
it is working as desired. However, I think you have introduced a new
bug in the code. In fact, if I compile a file with the "info" option,
then I become the following error:

....
(/home/beffa/texmf/tex/generic/tex4ht/tex4ht.4ht
::::::::::::::::::::::::::::::::::::::::::
TeX4ht info is available in the log file
::::::::::::::::::::::::::::::::::::::::::
) (/home/beffa/texmf/tex/generic/tex4ht/tex4ht.sty
--- needs --- tex4ht simple ---
(./simple.tmp) (./simple.xref)
(/home/beffa/texmf/tex/generic/tex4ht/info4ht.4ht)
(/home/beffa/texmf/tex/generic/tex4ht/infoht4.4ht
! Missing number, treated as zero.
t
l.3 ...\infoIVht#1//{}\fi\infoIVht[tml4ch1]76...//

?

-----------------
The above error does not show up without the "info" option.

Fede


 0
Reply beffa (6) 2/16/2004 2:54:19 PM

> I think you have introduced a new
> bug in the code. In fact, if I compile a file with the "info" option,

Thanks. I loaded new files with a fix to the problem. -eitan


 0
Reply gurari (142) 2/16/2004 4:07:09 PM

5 Replies
69 Views

Similar Articles

12/7/2013 7:14:05 AM
page loaded in 53936 ms. (0)