1

I am making a table, with one column. The table is centered. The column type is centered paragraph.

I am using \downarrow for annotation between each row to indicate transformation made.

In pdf, everything is centered. But in HTML, the math is centered, but the arrows are not. This happens only when I use column type as centered paragraph. If I use just c, then the arrows are centered.

But I have to use centered paragraph and not c for column type, because I am using displayed math in table, which needs paragraph. I am using displayed math because the math is little larger and easier to read.

Here is an example that works same way in PDF and HTML, which using c. Then below that I show an example which does not work in HTML when I change the column type to centered paragraph

\documentclass[12pt,oneside]{book}  

%added nov 23, 2023 to enlarge vertical arrow.
%https://tex.stackexchange.com/questions/213811/how-to-elongate-down-arrow
\newcommand{\xdownarrow}[1]{%
  {\left\downarrow\vbox to #1{}\right.\kern-\nulldelimiterspace}
}
\usepackage{amsmath}

\begin{document}

\begin{table}
\centering
\begin{tabular}{c}
$\int \frac{e^{x+e^x} \left(e^x+1\right)}{x+e^x} \, dx$\\
$\Big\downarrow$ \rlap{7258}\\
$\int \frac{e^{x+e^x}}{x+e^x}d\left(x+e^x\right)$\\
$\Big\downarrow$ \rlap{2609}\\
$\operatorname{ExpIntegralEi}\left(x+e^x\right)$
\end{tabular}
\end{table} 

\end{document}

Compiling with lualatex gives

enter image description here

Compiling with tex4ht using

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

Gives

enter image description here

Output is similar. arrows are centered

Now I modified the MWE to using column type centered paragraph so I can use display math

\documentclass[12pt,oneside]{book}  
%added nov 23, 2023 to enlarge vertical arrow.
%https://tex.stackexchange.com/questions/213811/how-to-elongate-down-arrow
\newcommand{\xdownarrow}[1]{%
  {\left\downarrow\vbox to #1{}\right.\kern-\nulldelimiterspace}
}

\usepackage{array}
%see https://tex.stackexchange.com/questions/12703/how-to-create-fixed-width-table-columns-with-text-raggedright-centered-raggedlef
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\usepackage{amsmath}    
\begin{document}
\begin{table}
\centering
\begin{tabular}{C{\textwidth}}
$\displaystyle \int \frac{e^{x+e^x} \left(e^x+1\right)}{x+e^x} \, dx$\\
$\Big\downarrow$ \rlap{7258}\\
$\displaystyle \int \frac{e^{x+e^x}}{x+e^x}d\left(x+e^x\right)$\\
$\Big\downarrow$ \rlap{2609}\\
$\displaystyle \operatorname{ExpIntegralEi}\left(x+e^x\right)$
\end{tabular}
\end{table}

\end{document}

Now lualatex gives

enter image description here

But tex4ht gives using same command as above this:

enter image description here

The arrows for some reason no longer centered as in PDF.

Is there an easy workaround for this?

TL 2023 updated about 2 months ago.

Tex4ht tracking number

4
  • Did you try the tikz-cd package? But I don't know how well the output can be converted with tex4ht. Commented Nov 22, 2023 at 8:46
  • @JasperHabicht I did not. That is way much more complicated for me than just using table and downarrow. I am not very good with tikz, also since I have to compile everything to HMTL also, I try to avoid using tikz unless necessary. tex4ht supports tikz graphics, but there can be some issues.
    – Nasser
    Commented Nov 22, 2023 at 8:48
  • 1
    The problem is that there is a number right to the arrow which makes it shift to the left (so that everything in this cell is centered, not only the arrow). To avoid this, you can place the number in a zero-sized box, e.g. with \rlap{7258}. Since \rlap is a quite basic command (but not for use in math mode), I would guess that the conversion works well. But I did not test it. Commented Nov 22, 2023 at 8:50
  • @JasperHabicht Ok, thanks. Will use your suggestion and update the MWE
    – Nasser
    Commented Nov 22, 2023 at 8:52

1 Answer 1

1

Try this configuration file:

\Preamble{xhtml}

\catcode`\:=11
\Configure{halignTD} {}{}
   {<}{\HCode{ style="white-space:nowrap; text-align:left;"}}
   {-}{\HCode{ style="white-space:nowrap; text-align:center;"}}
   {>}{\HCode{ style="white-space:nowrap; text-align:right;"}}
   {^}{\HCode{ style="vertical-align:top; white-space:nowrap;"}}
   {=}{\HCode{ style="vertical-align:baseline; white-space:nowrap;"}}
   {|}{\HCode{ style="vertical-align:middle; white-space:nowrap;"}}
   {_}{\HCode{ style="vertical-align:bottom; white-space:nowrap;"}}
   {p}{\HCode{ style="white-space:normal; text-align:left;"}\Protect\a:HColWidth}
   {m}{\HCode{ style="white-space:normal; text-align:center; vertical-align:middle;"}\Protect\a:HColWidth}
   {b}{\HCode{ style="white-space:normal; text-align:left; vertical-align:bottom;"}\Protect\a:HColWidth}
   {}
\catcode`\:=12
\begin{document}
\EndPreamble

It is a configuration for possible values of table column specifications. In theory, it should be possible to add line for your C specification here, but it seems that it is converted to m specification by array internally. So I've changed the configuration for m to align to center: {m}{\HCode{ style="white-space:normal; text-align:center; vertical-align:middle;"}\Protect\a:HColWidth}. I won't change it in TeX4ht sources, because m columns should be normally left aligned. Hopefully, this won't cause issues in your other tables.

This is the result:

enter image description here

10
  • Thanks Michael. This worked on the small examples I have. Will test it more on a large document with lots of tables also, but that takes 2 days to compile.
    – Nasser
    Commented Nov 22, 2023 at 9:27
  • @Nasser it compiles two days with MathJax math? That's insane. You could try to use -m draft for subsequent compilations for speed up.
    – michal.h21
    Commented Nov 22, 2023 at 9:35
  • I am not sure what you mean by use -m draft for subsequent compilations and how. I am using your lua script you send me long time ago which decides if it needs to do more runs or not. Remember that? The large document is this I normally start the build on friday night and by early sunday it is done. I do not want to use "draft" then having to compile everything again? right? I always complained that tex4ht is very slow on large documents. May be because I am on Virtual box.
    – Nasser
    Commented Nov 22, 2023 at 9:52
  • Yes, this is using mathjax mode. That is all I use now. svg for math will probably take 7 days to compile this document. And I also think math in mathjax looks better than math using svg images.
    – Nasser
    Commented Nov 22, 2023 at 9:53
  • Ah, you use this script. I forgot about it, of course. Anyway, if you use VirtualBox, does it mean that you always start from scratch, without temporary files from previous compilations? This can lead to additional runs.
    – michal.h21
    Commented Nov 22, 2023 at 10:35

You must log in to answer this question.

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