3

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

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

This is my table

\begin{table}[H]
\centering
\begin{tabular}[c]{|c|c|}\hline
A & B \\\hline
853.075 (sec) & 43.711 (sec)\\\hline
14.218 (minutes) & 0.729 (minutes)\\\hline
\end{tabular}
%\caption{Total real time used to solve all problems}
\end{table}

my table is done

This is my long table

\begin{longtable}[c]{|c|c|}\hline
A & B \\\hline
853.075 (sec) & 43.711 (sec)\\\hline
14.218 (minutes) & 0.729 (minutes)\\\hline
\end{longtable}

my long table is done

\end{document}

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
3

This is easy to fix using bit CSS:

\Preamble{xhtml}
\Css{table.longtable{margin-left: auto;margin-right:auto;}}
\begin{document}
\EndPreamble

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.