# why tex4ht adds extra frame when table inside longtable?

This is related to tex4ht only.

tex4ht adds extra frame around tabular when it is a cell inside longtable but not when it is on its own. How to fix this issue?

MWE

\documentclass[11pt]{article}
\usepackage{longtable}
\begin{document}

When table inside long table, it adds extra frame

\begin{longtable}{|p{1.75in}p{1.75in}|}\hline
\begin{tabular}{p{1.75in}}
entry 1
\end{tabular}
&
\begin{tabular}{p{1.75in}}
entry 2
\end{tabular}
\\\hline
\end{longtable}

When table on its own, no extra frame shows up

\begin{tabular}{p{1.75in}}
entry 1
\end{tabular}
\end{document}


PDF output is correct

But html, after compiling using the command

 make4ht -ulm default -a debug  foo3.tex "htm,mathjax"


shows this

btw, This is not related to using longtable in tex4ht, even tabular inside tabular adds these extra frames to the inner tabular when not asking for them. MWE. Gives similar output as above in HTML

\documentclass[11pt]{article}
\begin{document}

When table inside table also, it adds extra frame

\begin{tabular}{|p{1.75in}p{1.75in}|}\hline
\begin{tabular}{p{1.75in}}
entry 1
\end{tabular}
&
\begin{tabular}{p{1.75in}}
entry 2
\end{tabular}
\\\hline
\end{tabular}

When table on its own, no extra frame shows up

\begin{tabular}{p{1.75in}}
entry 1
\end{tabular}

\end{document}


It seems that tex4ht inherits or uses the frame setting from the outer table if any for the frame.

Using TL 2020

This is CSS issue. This is what you have in the generated CSS file:

#TBL-1 colgroup{border-left: 1px solid black;border-right:1px solid black;}


It sets border to left and right border of the table with id TBL-1. But because of how HTML and CSS works, this declaration is used also for tables that are child tables of this table.

To fix this, you need to provide custom CSS. Note that it is practically impossible to do this in a general way, so you need to fix particular tables by hand.

Try this .cfg file:

\Preamble{xhtml}
\Css{\#TBL-1 table colgroup{border:none;}}
\begin{document}
\EndPreamble


It disables border of tables that are children of TBL-1. You should add such fixes only when your document is done, because each table inserted before the configured one will change the ID and you would need to change the config file.

This is the result: