[tex4ht] [bug #509] Incompatibilities with Tikz generated by menukeys package

Michal Hoftich puszcza-hackers at gnu.org.ua
Fri May 7 22:49:24 CEST 2021


Update of bug #509 (project tex4ht):

             Open/Closed:                    Open => Closed                 

    _______________________________________________________

Follow-up Comment #15:

\Picture+ works as inline command, \Picture* can contain paragraphs.

It is possible to specify graphics path using "imgdir:path" option (like
`make4ht filename.tex "imdir:img/"`), but the images are not copied
automatically to this place. You can use the following build file:


----------------------------------
local log = logging.new("build file")

local imgdir 

local function get_imgdir(par)
  -- try to find imgdir:path in tex4ht options
  local imgdir = par.tex4ht_sty_par:match("imgdir:([^,]+)")
  if not imgdir then
    imgdir = ""
    log:warning("Cannot find imgdir")
    log:warning('Please use: make4ht ' .. par.input .. ' "imgdir:path"')
  end
  return imgdir
end

local function make_img_name(name, par)
  imgdir = imgdir or get_imgdir(par)
  -- don't make new name if the image name already contains imgdir path
  if string.find(name, imgdir, 1, true) then return name end
  local name_parts = {}
  -- construct output image name from make4ht output dir, imgdir and image
name
  if imgdir ~= "" then name_parts[#name_parts+1] = imgdir end
  name_parts[#name_parts + 1] = name
  -- turn name parts into path and normalize slashes
  local newname = table.concat(name_parts, "/"):gsub("/+", "/")
  return newname
end


local function copy_img(name, par)
  local newname = make_img_name(name, par)
  -- copy imge to the output dir
  if newname ~= name then
    if par.outdir~="" then newname = table.concat({par.outdir, newname}, "/")
end
    mkutils.copy(name, newname)
    return false, "Copy generated images to " .. imgdir
  end
end



Make:match("svg$", copy_img)
Make:match("png$", copy_img)
Make:match("jpg$", copy_img)

----------------

Call it as:

make4ht -e build.lua filename.tex "imgdir:graphics/"

    _______________________________________________________

Reply to this item at:

  <http://puszcza.gnu.org.ua/bugs/?509>

_______________________________________________
  Message sent via/by Puszcza
  http://puszcza.gnu.org.ua/



More information about the tex4ht mailing list.