There are two problems. First one is a wrong configuration for the array
package, which is required by makecell
. It somehow breaks the default configuration for tabular in the ooffice
output. The offending code is a following snippet:
\ifTag{vis-\TableNo-\HRow}%
{\special{t4ht@[}\gdef\end:box{\special{t4ht@]}}}%
{\global\let\end:box\empty}%
The \ifTag
command checks a existence of cross-reference defined in the .xref
file - tex4ht
keeps stuff like hyperlinks and other information needed between compilations. The code
{\special{t4ht@[}\gdef\end:box{\special{t4ht@]}}}%
is executed on the next and following compilations after the table have been added to the document. It disables processing of characters and spaces using \special{t4ht@[}
, their processing is enabled with \special{t4ht@]}
, which is executed in \end:box
macro. The problem is that the instruction \special{t4ht@]}
is inserted one more time somewhere in the process. This causes tex4ht
to immediately stop the output, so the XML file stops inside the table and rest of the document is omitted. The XML file is of course invalid. It all happens only at second and subsequent compilations, not on the first one, which makes it even harder to trace source of this issue.
I don't really know why this whole thing is used anyway, I cannot see a difference when it is omitted. I hope it is safe to delete it. Because ooffice.4ht
is huge, I will post only needed patch here:
--- /usr/local/texlive/2018/texmf-dist/tex/generic/tex4ht/ooffice.4ht 2018-06-08 00:41:40.000000000 +0200
+++ makecell/ooffice.4ht 2018-06-15 14:24:09.787127871 +0200
@@ -1794,8 +1794,9 @@
%
}
{\HCode{</table:table>}}
- {\ifTag{vis-\TableNo-\HRow}%
- {\special{t4ht@[}\gdef\end:box{\special{t4ht@]}}}%
+ {
+%\ifTag{vis-\TableNo-\HRow}%
+ %{\special{t4ht@[}\gdef\end:box{\special{t4ht@]}}}%
{\global\let\end:box\empty}%
%
\HCode{<table:table-row \Hnewline
The second issue is that the subtables inserted by makecell
are places inside paragraphs, which is not supported by the ODT format. It is hard to fix that using just macros, it is better to use a make4ht
filter.
File mybuild.mk4
:
local domfilter = require "make4ht-domfilter"
local process = domfilter {
function(dom)
-- process all tables which are child nodes of text:p element, which is forbidden
for _, table in ipairs(dom:query_selector("text|p table|table")) do
print "*******************************************"
-- replace the text:p with table:table
local parent = table:get_parent()
parent:replace_node(table)
print(parent:get_parent():serialize())
end
return dom
end
}
Make:match("4oo", process)
Note that the development version of make4ht
, not the version on CTAN is needed. Compile using:
make4ht -e mybuild.mk4 -f odt filename.tex
This is the result:

makecell
redefines internal LaTeX macros for table handling, which breakstex4ht
table support. I will look at this issue later.makecell
really breaks something withtex4ht
, the second is that there was wrong detection of tables nested inside other tables in tex4ht, the third is that LibreOffice doesn't seem to like nested tables. I need to investigate it moe.makecell
andtex4ht
(though that might be useful from a general point of view). If there's something reasonable that substitutes its function, I'd be already very glad. What I'm trying to do at the moment is to devise a LaTeX workflow that also leaves me with an .odt when needed. So I'm mapping what of the usual features I employ in LaTeX actually work withtex4ht
(This means I may come up with more stuff this week).Makecell
really breaks tex4ht, but it should be possible just normal nested tabulars, it is only necessary to edit the XML file, usingmake4ht
script