I have a latex table defined with array and tabularx, see code below.
In the PDF, it looks fine:
When I convert it to epub, it gets completely mangled:
Do I have any hope of fixing that, or should I abandon epub? I am currently thinking I should probably just distribute the PDF itself, to be sure it looks okay. However, it would be nice if it could be read on e-readers.
Making epub out of latex is hard. I ended up using this workflow:
latexml --dest tmp/book.xml main.tex
latexmlpost -dest=tmp/book.html tmp/book.xml
ebook-convert tmp/book.html tmp/book.epub --language en --no-default-epub-cover
Beginning of latex table code:
% centered X for tabularx
% see https://tex.stackexchange.com/a/89932
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\newcommand{\tx}{{\tt X}}
\newcommand{\ty}{{\tt Y}}
[
% two rows of five tables each:
\begin{array}{c}
%%%%% FIRST ROW
% five position tables:
\begin{array}{cccc}
% position table 1 (table and caption):
\begin{array}{c}
\begin{tabularx}{50pt}{|Y|Y|Y|Y|}
\hline
\tx & & & \ \hline
\ty & \ty & \tx & \ \hline
& & & \ \hline
& & & \ \hline
\end{tabularx} \
\textrm{position 1}
\end{array}
% position table 2 (table and caption):
\begin{array}{c}
\begin{tabularx}{50pt}{|Y|Y|Y|Y|}
\hline
\tx & & & \ \hline
& & \tx & \ \hline
\ty & \ty & \ty & \ty \ \hline
& & & \ \hline
\end{tabularx} \
\textrm{position 2}
\end{array}
% position table 3 (table and caption):
\begin{array}{c}
\begin{tabularx}{50pt}{|Y|Y|Y|Y|}
\hline
\tx & & & \ \hline
& & & \tx \ \hline
& & & \ \hline
& & & \ \hline
\end{tabularx} \
\textrm{position 3}
\end{array}
% position table 4 (table and caption):
\begin{array}{c}
\begin{tabularx}{50pt}{|Y|Y|Y|Y|}
\hline
\tx & & & \ \hline
& & & \tx \ \hline
\ty & \tx & & \ \hline
& & & \ \hline
\end{tabularx} \
\textrm{position 4}
\end{array}
% position table 4 (table and caption):
\begin{array}{c}
\begin{tabularx}{50pt}{|Y|Y|Y|Y|}
\hline
\tx & & & \ \hline
& & & \tx \ \hline
& \tx & & \ \hline
\ty & \ty & \ty & \ty \ \hline
\end{tabularx} \
\textrm{position 5}
\end{array}
\end{array}
\
\
%%%%% SECOND ROW
% ...


\begin{tabular}{|p{12pt}|p{12pt}|p{12pt}|p{12pt}|}– David Carlisle Aug 29 '21 at 15:05\tthas not been defined by default in latex since 1993 have you seen it used in a tutorial somewhere? We could try to get the tutorial fixed. – David Carlisle Aug 29 '21 at 15:17