tex4ebook doesn't copy images, you need to do it using a build file. I've handled a similar case some time ago in this answer, but it doesn't work correctly with tex4ebook. Here is a fixed version, which also contains other DOM filter that you want to use:
local mkutils = require "mkutils"
local domfilter = require "make4ht-domfilter"
local allowed_chars = {
["-"] = true,
["."] = true
}
local function fix_colons(id)
-- match every non alphanum character
return id:gsub("[%W]", function(s)
-- some characters are allowed, we don't need to replace them
if allowed_chars[s] then return s end
-- in other cases, replace with underscore
return "_"
end)
end
local function id_colons(obj)
-- replace : characters in links and ids with unserscores
obj:traverse_elements(function(el)
local name = string.lower(obj:get_element_name(el))
if name == "a" then
local href = el:get_attribute("href")
-- don't replace colons in external links
if href and not href:match("[a-z]%://") then
local base, id = href:match("(.)%#(.)")
if base and id then
id = fix_colons(id)
el:set_attribute("href", base .. "#" .. id)
end
end
end
local id = el:get_attribute("id")
if id then
el:set_attribute("id", fix_colons(id))
end
end)
return obj
end
local function fix_img_names(dom)
for _, img in ipairs(dom:query_selector("img")) do
local src = img:get_attribute("src")
if src then
-- remove path specification
src = src:match("([^/]+)$")
img:set_attribute("src", src)
end
end
return dom
end
local process = domfilter {id_colons,fix_img_names}
local function image_copy(path, parameters)
-- get image basename
local basename = path:match("([^/]+)$")
-- if outdir is empty, keep it empty, otherwise add / separator
local outdir = parameters.outdir == "" and "" or parameters.outdir .. "/"
-- handle trailing //
outdir = outdir:gsub("//$","/")
local output_file = outdir .. basename
for pos, name in pairs(Make.lgfile.files) do
if name == path then
Make.lgfile.files[pos] = output_file
end
end
mkutils.cp(path, output_file)
end
Make:match("png$", function(path, parameters)
image_copy(path, parameters)
-- prevent further processing of the image
return false
end)
Make:match("jpg$", function(path, parameters)
image_copy(path, parameters)
-- prevent further processing of the image
return false
end)
if mode=="draft" then
Make:htlatex {}
else
Make:htlatex {}
Make:xindy {modules={"duden-utf8"}}
Make:biber {}
Make:htlatex {}
Make:htlatex {}
end
Make:match("html$", process)
Details on how it works are in the link above.
\graphicspath{}of thegraphicxpackage, I discovered that image file name with-in it, will not be found or asnot exists. For example an image file with nameimage-name.jpgorthis-is-a-longer-image-name.jpgwill be found asnot exists. Whereasimagename.jpgwill get no error message and the generated epub will show the image file. Can you see this too? Or is there anything else with my system? – Thomkrates Apr 12 '23 at 19:38\coverimage[]{AbsolutPath/imagename.jpg}. Then it generated an epub with no error runnig epubcheck. (In two of my projects). But with the same issues while using an imagename likeThis-is-a-longer-image-name.jpg(in another project) it does generate an epub without error code, but lacks the image in the epub and is not shown there. Additionally an error with epubcheck"Absolutepath/This-is-a-longer-image-name.jpg" must be located in EPUB container. Is this reproduceable by your system? – Thomkrates Apr 12 '23 at 20:55-works for me, but I am on Linux. Do you use forward slashes in your file paths, or backslashes? – michal.h21 Apr 13 '23 at 10:44-seem not to be the problem. But I do not understand why I get discrepancies, since 2 of my sourcenameX.tex result in a epub with 0 error epubcheck. But with a third sourcenameY.tex it gives the error that theim-age-na-me.jpg not exists. And: No the slashes are correct in all paths the same. I really looked closely to the similarities between the 2 working sourcenameX.tex and hoped to get again a third epub with 0 error in epubcheck. But I can not find a hint where the difference is that is resulting in the error in epubcheck. - Any other ideas? – Thomkrates Apr 13 '23 at 18:05\pageref{somelabel}. This is strange, since pageref appears in ordinary text body and nothing else with it. In the epub the pageref-number is anon-functional hyperlink, and therefore the error message with epubcheckFragmentbezeichner is missing. What could here be missing? – Thomkrates Apr 13 '23 at 20:25-c myconfig.cfgand the-e build.luasince a MWE with minimal\pageref{}and minimal\index{}and minimalbibliographydid not reproduce the error in epubcheck. All minimalpagerefs worked in the epub(while in my sourcename.tex - with myconficg.cfg and build.lua the pageref in the epub do not work and do get 20 errors in epubcheck). So I will need to look at mypackages in sourcename.texand strategically look for the problem. – Thomkrates Apr 14 '23 at 18:39\pagerefshould work correctly. They probably point to some\labelthat is missing in the HTML file. – michal.h21 Apr 14 '23 at 18:53same preambleafter\documentclassas in the sourcename.tex and the error in epubcheck couldnotbe reproduced. I also looked in the html files for the\label{somelabelx}and checked the somelabelx within the sourcename.tex. But I could not find a lack of labels; all labels are present as pageref, for all pagerefs there is a label. I used the packagerefcheckand no warning can be found in the log file. But the 20 errors in epubcheck remain sayingFragmentbezeichner ist nicht angegeben(Some fragmented label is not specified). – Thomkrates Apr 14 '23 at 20:34sigil. Do you know about it? It is said, that this is anepub-editor, which might be able to resolve the pageref-errors which result here via epubcheck. Do you think that could be possible? – Thomkrates Apr 17 '23 at 09:54tex4ebook, because when you use manual edits, you would need to do them again when you recompile your book. Is it really not possible to make a MWE for this? – michal.h21 Apr 17 '23 at 10:09https://tex.stackexchange.com/questions/683283/errors-with-epubcheck-after-tex4ebook-concerning-pagerefsomelabelfor a MWE. – Thomkrates Apr 18 '23 at 20:54