[tex4ht] Too many DVI errors. stack empty at pop command, conficts, bm package, siunitx, dvilualatex

Michal Hoftich michal.h21 at gmail.com
Sat Jan 2 01:42:17 CET 2016

Hi Karl,

On Fri, Jan 1, 2016 at 11:56 PM, Karl Berry <karl at freefriends.org> wrote:
> I'm not sure if you determined if all of this is a dvisvgm bug,
> but if not:
>     Here is a MWE, which shows the issue. What happens is that
>     DVI creates corrupted DVI file or has an error making the dvi.
> When dviluatex (or any engine) creates a corrupted DVI file (i.e.,
> dvitype cannot successfully read it), under any reasonable
> circumstances, it's certainly an error.

For the file minimal.tex, I've got the error regardless of the used
engine, and the DVI file doesn't seem corrupted, both dvitype and
dviasm can open it. Also dvipng can convert it. But PS specials are
used, so that might be the culprit.

This is really strange, xfrac uses \raisebox from graphicx package,
this seems to be possible source of the PS specials. When I've tried
to add `\usepackage[dvipdfmx]{graphicx}`, dvisvgm compiled the
document without problems. This explains why Nassed didn't get an
error, because there was explicit
`\RequirePackage[dvipdfmx]{graphicx}` in the .mk4 file.

So this one seems like dvisvgm error. Could anyone try to run
minimal.tex with both dvilualatex and latex and dvisvgm?

Now back to Nasser's case, there are more problems it seems:

1. you should define image format to be svg in the .cfg file:


otherwise you compile the images to svg, but in the document png are requested.

2. you used the wrong .mk4 file, you should use the previous one:


Make:add("dvisvgm","dvisvgm -n -TS1.25,1.25 -c 1.2,1.2 -p 1- ${input}.idv")

local max_count = 5
local image_format = "${input}-${zeroes}${page}.${ext}"
local oneimage_format = "${input}.${ext}"

local function file_exists(fn)
  local f = io.open(fn,"r")
  if f ==  nil then return false else f:close() return true end

local function locate_file(par,ext, count)
  local count = count or 0
  par.ext = ext
  local zeroes = string.rep("0",count)
  par.zeroes = zeroes
  if count > max_count then
    local one = oneimage_format % par
    if file_exists(one) then
      return one
      return false, "max_count exceeded"
  local fn = image_format % par
  if file_exists(fn) then
    return fn
    return locate_file(par, ext, count+1)

if mode=="draft" then
  Make:htlatex {}
  Make:htlatex {}
  Make:htlatex {}
  Make:htlatex {}
Make:tex4ht {}
Make:t4ht {}
  arg.input = arg.source:gsub(".idv$","")
  local fn,msg = locate_file(arg, "svg")
  if not fn then
    print("Image processing error: "..msg)
    arg.filename = fn
    local cmd = "mv ${filename} ${output}" % arg

3. The strange thing is that dvisvgm can convert foo.dvi, but not
foo.idv. So it seems that corrupted file is created by tex4ht

4. when bm package is not used, the compilation goes without problems.
There is bm.4ht file, so we should investigate it further.

Best regards,

More information about the tex4ht mailing list