[l2h] LyX an LaTeX2html cannot handle tables

Ross Moore ross at ics.mq.edu.au
Sun Aug 29 10:16:35 CEST 2004


Hello Heiko,


On 29/08/2004, at 3:37 PM, Heiko Schröder wrote:

> Hello Ross,
>
> thank you *very* much that you respond so quickly!
>
>> Many people process tables quite happily using LaTeX2HTML.
> Yes, and I belonged to those people with the former versions in the 
> last four
> distributions of SuSE ;-).
>
>> It would help a great deal if you provided an example of the kind of
>> table
> Yes, here it comes: the two examples are containing only a table of 
> two rows
> with three columns. The first row contains the numbers 1, 2, 3 and the 
> second
> the words one, two, three. But the first, correct one lies within a 
> section,
> and the second, incorrect one within a subsection.



>
> ------------- schnipp first example only with section ---------------
>
> %%LyX specific LaTeX commands.
> %% Because html converters don't know tabularnewline
> \providecommand{\tabularnewline}{\\}
>
> \usepackage{babel}
> \makeatother
> \begin{document}
>
> \section{This is a section}
>
> \begin{tabular}{|c|c|c|}
> \hline
> 1&
> 2&
> 3\tabularnewline

The problems stem from this use of  \tabularnewline
instead of just using \\  as most authors would do.

LaTeX2HTML was initially written to cope with the kind
of markup that most authors can be expected to want to use.
Other constructions may need to be specially catered-for.

In fact, LaTeX2HTML does support use of  \tabularnewline
when the {longtable} package is loaded:

    \usepackage{longtable}

for tables that would extend over more than 1 printed page.
But it is only recognised within the environment:

   \begin{longtable}
     ...
   \end{longtable}



It seems that now  \tabularnewline  is recognised by LaTeX
in {tabular} environments, as well as {longtable}.
I don't know when that was introduced.
It would be appropriate for LaTeX2HTML to be updated
to support this too.


> \hline
> \hline
> one&
> two&
> three\tabularnewline
> \hline
> \end{tabular}
> \end{document}
>
> ----------------------- end schnipp -----------------------------
>
> This leads to a correct translation of the site and the table appears 
> as the
> listing shows:
>
> <H1><A NAME="SECTION00010000000000000000">
> This is a section</A>
> </H1>
>
> <P>
> <TABLE CELLPADDING=3 BORDER="1">
> <TR><TD ALIGN="CENTER">1</TD>
> <TD ALIGN="CENTER">2</TD>
> <TD ALIGN="CENTER">3</TD>
> </TR>
> <TR><TD ALIGN="CENTER">one</TD>
> <TD ALIGN="CENTER">two</TD>
> <TD ALIGN="CENTER">three</TD>
> </TR>
> </TABLE>
>

The  \providecommand{\tabularnewline}{\\}  has resulted
in an early substitution of the \\s,
so this coding works as intended.

>
> But the next example with subsections gets a bad result. The TeX-File 
> is:
>
> -------------------- schnipp example with section and 
> subsection-------------
> %%%%%% LyX specific LaTeX commands.
> %% Because html converters don't know tabularnewline
> \providecommand{\tabularnewline}{\\}
>
> \usepackage{babel}
> \makeatother
> \begin{document}
>
> \section{This is a section}
>
>
> \subsection{This is a subsection}
>
> \begin{tabular}{|c|c|c|}
> \hline
> 1&
> 2&
> 3\tabularnewline
> \hline
> \hline
> one&
> two&
> three\tabularnewline
> \hline
> \end{tabular}
> \end{document}
>
> -----------------------  end schnipp -------------------
>
> I cannot see any differences in the TeX-Files according to the
> tabular-environment, but the HTML result this time is:
>
> <H2><A NAME="SECTION00011000000000000000">
> This is a subsection</A>
> </H2>
>
> <P>
> <TABLE CELLPADDING=3 BORDER="1">
> <TR><TD ALIGN="CENTER">1</TD>
> <TD ALIGN="CENTER">2</TD>
> <TD ALIGN="CENTER">3
> <BR>
> one</TD>
> </TR>
> </TABLE>

But here, the  \tabularnewline  has not been substituted-for early.
Instead it has been later treated as  \newline  within a table-cell.

> Very peculiar is, that the first entry of the second row now appears 
> in the
> last cell of the first line. But nothing else follows. All other rows 
> an
> contents do not appear.

LaTeX2HTML has seen this as a table with just a single row of cells,
and discarded all the excess cells.

>
> Hm, do you have an idea?

I'm not at all sure about why the 2 situations produced different 
results.
I have some ideas about how this may have occurred; but in any case, 
it's
not right that this is happening.



Anyway, until I patch this bug in LaTeX2HTML, there is an easy fix
that you can use:

replace the line
    \providecommand{\tabularnewline}{\\}
with the TeX definition:
    \def\tabularnewline{\\}

This certainly works with your example, both with and w/out subsections.
It should be OK for normal LaTeX too, except perhaps with some exotic
packages that redefine \tabularnewline for themselves.


Hope this helps,

	Ross



>
> I use LaTeX2HTML Version 1.70. The first part above the line *LyX 
> specific
> LaTeX commands is in both cases the same:
>
> %% LyX 1.3 created this file.  For more info, see http://www.lyx.org/.
> %% Do not edit unless you really know what you are doing.
> \documentclass[ngerman]{article}
> \usepackage[T1]{fontenc}
> \usepackage[latin1]{inputenc}
> \setlength\parskip{\medskipamount}
> \setlength\parindent{0pt}
>
> \makeatletter
>
>
> Thanks a lot for your help
>
> Best regards from Heiko
> -- 
> Heiko Schröder
> Praha
> http://home.foni.net/~heikos
>
>
------------------------------------------------------------------------
Ross Moore                                         ross at maths.mq.edu.au
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia                                  fax: +61 +2 9850 8114
------------------------------------------------------------------------



More information about the latex2html mailing list