I am using MiKTeX on windows and calling tex4ebook.lua as a parameter to lualatex to make epub3.

Can somebody explain in simple terms what the .4ht files in the tex4ebook directory are used for Likewise exec_epub3.lua? If one were to modify, how to use them to generate custom ebook output?

  • 1
    The .4ht files are special configuration files used by tex4ht. For each .sty files if some configuration required is written on corresponding .4ht files. When an epub3 file is generated, tex4ebook first executes exec_epub.lua and later executes exec_epub3.lua. The exec_epub3.lua generates a TOC if it is not generated and cleans the content.opf file generated by exec_epub.lua. So if you need to adjust anything then it should be done using a custom config file (.cfg), exec_epub.lua and exec_epub3.lua as required.
    – Jagath
    Jul 18, 2016 at 3:22
  • Thanks much, I thought so but wanted to be sure.
    – TrustNoOne
    Jul 18, 2016 at 13:49

1 Answer 1


The tex4ebook compilation process is following:

  • tex4ebook is Lua script, which is called using texlua, interpreter distributed with TeX distributions. It prepares compilation parameters and load compilation module for specified output format. Each module has functions for preparing, executing and finalizing the compilation.

  • basic output module is exec_epub.lua, other modules uses it in the background and add some stuff needed for their formats.

  • make4ht is used to execute all necessary applications (most notably latex, tex4ht and t4ht. user can specify custom build file and select additional apps like bibtex or makeindex)

  • latex is called with special configuration, tex4ht.sty, tex4ebook.sty and tex4ebook.4ht are automatically loaded. In case of epub3, tex4ebook-epub3.4ht is loaded as well. tex4ebook.4ht is used mainly to create epub metadata, like the NCX and OPF files.

If you want to modify the tex4ebook behavior, it is best to use a custom configuration file

  • If I write a custom configuration file, I'd like to start from a default configuration file. Where can I find it, if there is any?
    – mmj
    Jul 31, 2016 at 15:03
  • @mmj the default configuration for HTML output is provided in html4.4ht file. It is generated file without comments, so it is not easily understandable. There is the documented source
    – michal.h21
    Jul 31, 2016 at 15:10

You must log in to answer this question.

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