when using \centering option in table, and then using either tabular or longtable then both come out centered in PDF as expected.

But in tex4ht, only the tabular comes out centered in middle of the web page, while the longtable is not centered and remained to the left edge of the webpage.

Here is a MWE


This is my table

A & B \\\hline
853.075 (sec) & 43.711 (sec)\\\hline
14.218 (minutes) & 0.729 (minutes)\\\hline
%\caption{Total real time used to solve all problems}

my table is done

This is my long table

A & B \\\hline
853.075 (sec) & 43.711 (sec)\\\hline
14.218 (minutes) & 0.729 (minutes)\\\hline

my long table is done


Compiled using lualatex foo.tex shows that both are centered in middle of page

Mathematica graphics

Using make4ht foo.tex "htm" only the tabular is centered:

Mathematica graphics

How to make longtable be centered as well?

  • \centering has no effect on a longtable and a longtable inside a table can not do anything useful, so remove the \begin[table}[H] and \centering. – David Carlisle Jan 30 at 20:49
  • @DavidCarlisle Ok, done. Thanks. – Nasser Jan 30 at 21:13
  • but you added \begin{center} which also does nothing useful for longtable. – David Carlisle Jan 30 at 21:23
  • @DavidCarlisle Ok, removed \begin{center} from long table also. Thaks. – Nasser Jan 30 at 21:25

This is easy to fix using bit CSS:

\Css{table.longtable{margin-left: auto;margin-right:auto;}}

The result:

enter image description here

I've also updated the tex4ht sources.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.