# Customizing ODT output from mk4ht oolatex

Inspired by the custom environments created from the cfg file referenced during mk4ht oolatex test.tex custom.cfg compilations as demonstrated in the answer Configure tex4ht/oolatex output

I'm wondering how far this can be taken. For example, starting with the test code in the aforementioned question, I've been unable to get any actual changes like font size changes or font changes to the text of this quote environment. Some change efforts are seen below in the lightly modified MWE. Specifically, I've tried to insert: style:font-name="Times New Roman" and fo:font-size="18pt" but I see no change to my odt file. I've tried a dozen or so logical variations to "font-name" like:

• font
• font-name
• fonts
• font-face
• font-family

but none have changed my formatting. The document compilation didn't crash either, so I'm not even sure if I'm successfully using this part of the cfg file.

Is there a list of oolatex parseable style properties anywhere in the documentation that I've missed?

custom.cfg

\Preamble{xhtml}

\makeatletter
\ConfigureEnv{quote}
{\ifvmode \IgnorePar\fi \EndP}
{\ifvmode \IgnorePar\fi\EndP\par\ShowPar}
{\EndP \ifvmode \IgnorePar\fi
\bgroup \Configure{HtmlPar}
{\EndP \HCode{<!--l. \the\inputlineno-->%
<text:p text:style-name="quote\if@rl-rtl\fi">}}
{\EndP \HCode{<!--l. \the\inputlineno-->%
<text:p text:style-name="quote\if@rl-rtl\fi">}}
{\HCode{</text:p>}}
{\HCode{</text:p>}}%
}
{\IgnorePar\EndP \egroup \ShowPar \ShowIndent}
\ConfigureOO{quote}{\Hnewline
<style:style style:name="quote"
style:font-name="Times New Roman"
fo:font-size="18pt"
style:family="paragraph"
style:parent-style-name="Text-body"
style:next-style-name="Text-body">\Hnewline
<style:paragraph-properties  fo:margin-left="2cm"
fo:margin-right="1cm"
fo:margin-top="0.199cm"
fo:margin-bottom="0.199cm"
fo:text-indent="0cm"
style:auto-text-indent="false"/>\Hnewline
</style:style>
\Hnewline <style:style style:name="quote-trl"
style:family="paragraph"
style:parent-style-name="Text-body-trl"
style:next-style-name="Text-body-trl">\Hnewline
<style:paragraph-properties  fo:margin-left="1cm"
fo:margin-right="1cm"
fo:margin-top="0.199cm"
fo:margin-bottom="0.199cm"
fo:text-indent="0cm"
style:auto-text-indent="false"
fo:text-align="end"
style:writing-mode="rl-tb"  />\Hnewline
</style:style>
\Hnewline
}
\makeatother
\begin{document}

\EndPreamble


test.tex

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}
This is a normal paragraph.

\begin{quote}
This is an blockquote.
\end{quote}

Another paragraph.
\end{document}


Ultimately I'd like to be able to control:

• fonts
• font sizes
• margin formatting
• paragraph spacing and alignment type (i.e. square or ragged)
• continuous section breaks
• column control (number of columns, spacing, etc)

But, baby steps in customizing styles (xml? or css?) in these office documents.

I think that font changes must be done in <style:text-properties> child element of <style:style>. See a list of possible attributes, another list. I cannot find any human readable description unfortunately. Anyway, try this:

\Preamble{xhtml}

\makeatletter
\ConfigureEnv{quote}
{\ifvmode \IgnorePar\fi \EndP}
{\ifvmode \IgnorePar\fi\EndP\par\ShowPar}
{\EndP \ifvmode \IgnorePar\fi
\bgroup \Configure{HtmlPar}
{\EndP \HCode{<!--l. \the\inputlineno-->%
<text:p text:style-name="quote\if@rl-rtl\fi">}}
{\EndP \HCode{<!--l. \the\inputlineno-->%
<text:p text:style-name="quote\if@rl-rtl\fi">}}
{\HCode{</text:p>}}
{\HCode{</text:p>}}%
}
{\IgnorePar\EndP \egroup \ShowPar \ShowIndent}
\ConfigureOO{quote}{\Hnewline
<style:style style:name="quote"
style:family="paragraph"
style:parent-style-name="Text-body"
style:next-style-name="Text-body">\Hnewline
<style:paragraph-properties  fo:margin-left="2cm"
fo:margin-right="1cm"
fo:margin-top="0.199cm"
fo:margin-bottom="0.199cm"
fo:text-indent="0cm"
style:auto-text-indent="false"/>\Hnewline
<style:text-properties
fo:font-size="18pt"
style:font-name="Times New Roman"
/>\Hnewline
</style:style>
\Hnewline <style:style style:name="quote-trl"
style:family="paragraph"
style:parent-style-name="Text-body-trl"
style:next-style-name="Text-body-trl">\Hnewline
<style:paragraph-properties  fo:margin-left="1cm"
fo:margin-right="1cm"
fo:margin-top="0.199cm"
fo:margin-bottom="0.199cm"
fo:text-indent="0cm"
style:auto-text-indent="false"
fo:text-align="end"
style:writing-mode="rl-tb"  />\Hnewline
</style:style>
\Hnewline
}
\makeatother
\begin{document}

\EndPreamble


This is the result:

Edit November 2018:

make4ht can output ODT file directly now, with filter support. So the code bellow can be simplified significantly:

local filter = require "make4ht-filter"

local process = filter {
function(content)
content = content:gsub("<office:font%-face%-decls>", [[<office:font-face-decls>
<style:font-face style:name="Times New Roman" svg:font-family="&apos;Times New Roman&apos;" style:font-family-generic="roman" style:font-pitch="variable"/>]])
return content
end
}

Make:match("styles.4oy$", process)  It can be executed using  make4ht -e buildfilename.mk4 -c configfile.cfg -f odt filename.tex  The styles.4oy$ file pattern matches file with ooffice styles and executes the filter which declares "Times New Roman" font to be used in the document.

Edit:

The Times New Roman is not used in the document because it is not declared. To declare new fonts, it is necessary to modify the styles.xml file. unfortunately, interface for this declaration is not provided by tex4ht, so we must use a trick involving mk4 build file:

local mkutils = require "mkutils"
local zip = require "zip"

tex4ht_sty_par = ",ooffice",
tex4ht_par =  " ooffice/! -cmozhtf",
t4ht_par =  " -cooxtpipes -coo "
}

Make:match("tmp\$", function(name, par)
local odtname = mkutils.remove_extension(name) .. ".odt"
local stylesname = "styles.xml"
local odtfile = zip.open(odtname)
local styles = odtfile:open("styles.xml")
styles:close()
odtfile:close()
content = content:gsub("<office:font%-face%-decls>", [[<office:font-face-decls>
<style:font-face style:name="Times New Roman" svg:font-family="&apos;Times New Roman&apos;" style:font-family-generic="roman" style:font-pitch="variable"/>]])
print(content)
local styles_file  = io.open(stylesname,"w")
styles_file:write(content)
styles_file:close()
os.execute("zip " .. odtname .. " " .. stylesname)
os.remove(stylesname)
end)


Use it as

make4ht -e buildfilename.mk4 -c configfile.cfg filename.tex


in TL 2018, it will be possible to create odt files directly using make4ht with make4ht -f odt. because it is not readily available, the settings for the odt output need to be set explicitly.

In the Make:match function, the settings.xml is extracted from the odt file and updated with declarations for Times New Roman.

• Thanks for the answer. The links with the lists of commands will definitely really help. I'm able to change the font size, as your image depicts, but I unfortunately am still getting Liberation Serif fonts. – EngBIRD Apr 20 '18 at 23:36
• @EngBIRD this is more complicated, it is necessary to define the font in styles.xml file, but tex4ht doesn't provide interface for that. I need to investigate this further. – michal.h21 Apr 21 '18 at 19:00
• @EngBIRD I think I've found a way, please see the edit – michal.h21 Apr 21 '18 at 19:51
• Thanks and sorry for the delay. I haven't been able to compile anything with make4ht instead of mk4ht, so I'm still troubleshooting and investigating. I'm sure I've still got much to investigate around the error make4ht:35: attempt to call field 'process_args' (a nil value) so I won't open a new question yet. I'm sure it's something silly I'm overlooking. Just wanted to leave a comment in the interim as I really appreciate your incredible contributions with this build file and configurations, and didn't want to appear to be ignoring them. Thanks again! – EngBIRD Apr 24 '18 at 3:14
• @EngBIRD do you use make4ht from your distribution, or manually installed version? if it is provided by distribution, which distribution do you use? it seems that some files are missing on your computer. – michal.h21 Apr 24 '18 at 7:51