1

my ebook created with tex4ebook contains cellspacing and cellpadding in tables. These attributes are not tolerated anymore (according to the ebookcheck). How can I remove them in the build process?

<div class='tabular'> <table class='tabular' cellspacing='0' cellpadding='0' id='TBL-3'><colgroup id='TBL-3-1g'><col id='TBL-3-1' /><col id='TBL-3-2' /><col id='TBL-3-3' /><col id='TBL-3-4' /><col id='TBL-3-5' /></colgroup><tr style='vertical-align:baseline;' id='TBL-3-1-'><td class='td11' id='TBL-3-1-1' style='white-space:nowr  ...

Kind regards

Hartmut

1 Answer 1

1

You can try this .cfg file:

\Preamble{xhtml}
\Configure{halignTB<>}{tabular}{%
\HCode{id="TBL-\TableNo" class="tabular"\Hnewline
   \GROUPS\Hnewline
 }<>\HAlign}
\begin{document}
\EndPreamble

The \Configure{halignTB<>} command configures contents of HTML attributes that are used in the <table> element. I took this definition from TeX4ht source code and removed cellspacing and cellpading.

The following sample file:

\documentclass{article}
\begin{document}
\begin{tabular}{|l| l|}
  \hline
  first & second\\
  \hline
  third & fourth\\\hline
\end{tabular}
\end{document}

Compiled using

tex4ebook -c mycfg.cfg sample.tex

Produces this HTML code:

<div class='tabular'> <table class='tabular' id='TBL-1'><colgroup id='TBL-1-1g'><col id='TBL-1-1' /></colgroup><colgroup id='TBL-1-2g'><col id='TBL-1-2' /></colgroup><tr class='hline'><td><hr /></td><td><hr /></td></tr><tr id='TBL-1-1-' style='vertical-align:baseline;'><td class='td11' id='TBL-1-1-1' style='white-space:nowrap; text-align:left;'>first</td><td class='td11' id='TBL-1-1-2' style='white-space:nowrap; text-align:left;'>second</td></tr><tr class='hline'><td><hr /></td><td><hr /></td></tr><tr id='TBL-1-2-' style='vertical-align:baseline;'><td class='td11' id='TBL-1-2-1' style='white-space:nowrap; text-align:left;'>third</td> <td class='td11' id='TBL-1-2-2' style='white-space:nowrap; text-align:left;'>fourth</td>
</tr><tr class='hline'><td><hr /></td><td><hr /></td></tr></table>
</div>  
1
  • Perfect, this works, thank you. I have one additional question but I will ask it in a separate post as not related.
    – berchas
    Commented Jan 10, 2021 at 13:28

You must log in to answer this question.

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