1

I have a simple *.tex file for this question:

\documentclass[12pt,letterpaper]{article}

\usepackage{lmodern}
\usepackage[T1]{fontenc}

\usepackage{amsmath}

\begin{document}

\title{A test \LaTeX to HTML page}

\section{Section One}
    Hello world. Here is some mathematics:
        \begin{equation}
            x + y = 3
        \end{equation}

\end{document}

The answer to this question taught me how to fix image quality issues (for equations, etc.) that I was having when using htlatex. So, when I run:

htlatex test_article.tex,

I get nice HTML output.


Now I am interested in doing the same thing, except with make4ht, but I have some questions after reading the documentation:

1) Why is htlatex() command repeated twice in the filters example?

local filter = require "make4ht-filter"
local process = filter{"cleanspan", "fixligatures", "hruletohr"}
Make:htlatex()   <--- first time
Make:htlatex()   <--- second time?
Make:match("html$",process)

2) Image conversion: the documentation recommends a command like this:

Make:image("png$",
"dvipng -bg Transparent -T tight -o ${output}  -pp ${page} ${source}")

How will ${output}, ${page} and ${source} be figured out? Is this automatic, or is this assuming that I have supplied these parameters somewhere? If the second, where should I supply these parameters?


So far, I have written the following in test_article.mk4:

local filter = require "make4ht-filter"
local process = filter{"cleanspan", "fixligatures", "hruletohr"}
Make:htlatex()
Make:htlatex()
Make:image("png$",
    "dvipng -bg Transparent -T tight -o ${output}  -pp ${page} ${source}")
Make:match("html$",process)
Make:match("html$", "tidy -m -xml -utf8 -q -i ${filename}")

I run the following command (-n for disable tex4ht):

make4ht "test_article.tex" -n

...but then get the following error:

----------------------------
t4ht.c (2012-07-25-19:28 kpathsea)
t4ht -p
  test_article.dvi
(a:/texlive/2015/texmf-dist/tex4ht/base/win32/tex4ht.env)
--- warning --- Can't find/open file `test_article.lg'
Parse LG
Cannot read log file: test_article.lg

Hopefully, this error is related to some of my questions that I have asked above.

2

1) the Make:htlatex runs LaTeX once, it isn't the same as calling htlatex script which runs LaTeX three times. It is called three times because of crossreferences and links.

You can speed the compilation using mode variable, which can be passed as command line parameter. I usually define draft mode where Make:htlatex is called only once and then compile with

make4ht -m draft filename

sample build file with mode variable:

local filter = require "make4ht-filter"
local process = filter{"cleanspan", "fixligatures", "hruletohr"}
if mode == "draft" then
  Make:htlatex()
else
  Make:htlatex()
  Make:htlatex()
  Make:htlatex()
end
Make:image("png$",
"dvipng -bg Transparent -T tight -o ${output}  -pp ${page} ${source}")
Make:match("html$",process)
Make:match("html$", "tidy -m -xml -utf8 -q -i ${filename}")

2) these parameters are set automatically, the image conversion is driven by the .lg file. Images are stored in special dvi file with .idv extension, it is the source parameter. every image is on standalone page, so page is number of the current converted image, output is the image name.

3) don't use the -n option, it disables tex4ht conversion from dvi to html, which is clearly not something you want

  • Thank you so much for make4ht, and your answer! You're right, I don't want the -n option, I misread it as the option to disable tex4ht from processing the image files -- how do I do that disabling (or is it automatic with the image function)? – user89 Jan 8 '16 at 22:01
  • @user89 the image processing is disabled by image function automatically. -n option should be passed to t4ht, you can pass it using mak4ht filename "" "" " -n", but you don't need it – michal.h21 Jan 8 '16 at 22:07
  • Very nice! I also just posted another question, if you are able to answer it: tex.stackexchange.com/questions/286723/… – user89 Jan 8 '16 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.